On Jan 4, 2010, at 5:59 PM, Nav wrote:

> On Jan 4, 4:54 pm, Chris Rebert <c...@rebertia.com> wrote:
>> On Mon, Jan 4, 2010 at 1:32 PM, Shawn Milochik <sh...@milochik.com> wrote:
>>> You could put them in a dictionary with the key being the name, instead of 
>>> a list.
>> 
>> To illustrate that for the OP:
>> 
>> name2drink = {}
>> for booze in liquors:
>>     for juice in juices:
>>         name = juice +" "+booze # or however you're naming them
>>         drink = Bottle(booze, juice)
>>         name2drink[name] = drink
>> 
>> #example use
>> favorite = name2drink["apple wine"]
>> favorite.rating = 9/10
> 
> typing
> favorite = such and such is what I am trying to avoid.
> 
> I want to be able to use the name 'apple_wine' as the variable which
> has the object apple wine but not have to do this manually as you did
> with favorite.
> 
> 
> 
> 
> 

Then don't assign a variable to favorite, and just use name2drink["apple wine"].
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to