Instance Names

Larry Bates larry.bates at websafe.com`
Thu Jul 3 15:20:14 EDT 2008


Tim Cook wrote:
> Hi All,
> 
> I have a need (if at all possible) to create instance names using '['
> and ']', i.e. [at0000]=ClassA0(), [at0001]=ClassB2(), etc.
> 
> Of course Python tries to unpack a sequence when I do that.  Is there
> anyway to do this?
> 
> I do have a workaround but it is an ugly, nasty URL mangling thing. :-)
> 
> Cheers,
> Tim
> 
> 
> 

I suspect there is some "misunderstanding" here.  Why exactly do you think you 
need to have your instances named with [] characters in them?


You could put them in a dictionary:

instances = {}

instance['[at0000']] = ClassA0()


but that isn't really different than:

instance['at0000'] = ClassA0()

-Larry



More information about the Python-list mailing list