[Tutor] objects becoming pointers

bob gailer bgailer at gmail.com
Wed Jul 15 23:38:42 CEST 2009

Please always reply-all so a copy goes to the list.

chris Hynes wrote:
> Ah, there you go, that's what I want to do, dynamically create 
> variable names. Then I could interactively create as many arrays as I 
> want to, say Chris1, Chris2, Chris3 and each of these would be 
> different array with different results.
> But based on what you showed me I'm going to have to at least type:
> print names["Chris"]
> as opposed to just typing:
> print Chris
True. As others have pointed out you may use exec to dynamically create 

Most Python applications pretty quickly evolve beyond simple command 
line interfaces. At that point dealing with dynamically created names 
becomes a pain.

With a little finessing you can create a class instance with attributes 
that are names such as Chris. Then you could
 >>> print c.Chris

Bob Gailer
Chapel Hill NC

More information about the Tutor mailing list