On Fri, Dec 18, 2009 at 3:03 PM, Tim Chase <python.l...@tim.thechases.com>wrote:
> Victor Subervi wrote: > >> How do I...? >> > > Well, you start by reading a book on how to program. You would then learn > that what you want (in all likelihood) is a dictionary/map structure for > dynamically created key/value pairs. Once you have progressed from your > current apprenticeship and achieved the rank of third-degree journeyman > programmer, the ways of dynamic variable creation will avail themselves. Why the arrogance? Why talk down to me? > > As stated above, you want a dictionary where your keys are > > 'optionNo%d' % i > > and your values are "i". You can also use the more idiomatic > > for i, option in enumerate(ourOptions()): > ... > > and skip the manual initialization and incrementation of "i". Or even more > succinctly, you could pass the above as a generator to the dict() > initialization. But that's a level-2 apprentice bit of code. Patience > grasshopper. > Why the arrogance? > > And as additional weirdness, you don't actually make use of "option" in > your for-loop... > The variable was tied to another set of variables that iterated through the options. Why be so judgmental? I appreciate your advice, after having filtered out the attitude. V
-- http://mail.python.org/mailman/listinfo/python-list