Object Reference question

Chris Rebert clp2 at rebertia.com
Fri Aug 21 02:39:41 EDT 2009


On Thu, Aug 20, 2009 at 11:34 PM, Miles Kaufmann<milesck at umich.edu> wrote:
> On Aug 20, 2009, at 11:07 PM, josef wrote:
<snip>
>> The following is what I would like to do:
>> I have a list of class instances dk = [ a, b, c, d ], where a, b, c, d
>> is an object reference. Entering dk gives me the object: [MyClass0
>> instance at 0x0000, MyClass1 instance at 0x0008, MyClass2 instance at
>> 0x0010 ... ]
>>
>> I need the object reference name (a,b,c,d) from dk to use as input for
>> a file.
>
> It sounds like you should either be storing that name as an attribute of the
> object, or using a dictionary ({'a': a, 'b': b, ...}).

Shorter way to produce the same dictionary:
dict(a=a, b=b, ...)

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list