Created
January 16, 2011 19:11
-
-
Save sritchie/782046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cntryList = ['VNM', 'TWN', 'THA', 'PHL', 'MYS', 'MMR', 'LKA', 'LAO', 'KHM', 'IND', 'IDN', 'CHN', 'BGD'] | |
# new version, using list comprehensions and default values | |
def messageList(useRange=False, testRange=range(71,126)): | |
rangedFunc = (lambda country: ['%s %s' % (country, i) for i in testRange]) | |
identityFunc = (lambda country: country) | |
entryFunc = useRange and rangedFunc or identityFunc | |
return [entry for country in countryList for entry in entryFunc(country)] | |
# new version, with in-line lambdas | |
def messageList(useRange=False, testRange=range(71,126)): | |
entryFunc = useRange and (lambda x: ['%s %s' % (x, i) for i in testRange]) or (lambda x: x) | |
return [entry for country in countryList for entry in entryFunc(country)] | |
# old version | |
def messageList(): | |
totalList = [] | |
for cntry in cntryList: | |
totalList.append('%s' %(cntry)) | |
#for j in range(71,126): | |
# totalList.append('%s %s' %(cntry, j)) | |
return totalList |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment