[Tutor] user-given variable names for objects
Che M
pine508 at hotmail.com
Thu Dec 13 05:35:44 CET 2007
I'm sure this is a classic beginner's topic, and I've read a bit about it online already, but I'd like to ask about it here as well. I want to assign names to objects based on what a user inputs so that I can later keep track of them.
In particular, I want to time multiple events by getting each of their start times and later comparing them to their respective stop times--I don't want to user timers. In order to do this, I need to give each start time a name associated with the name of the event. If there is an "event A" it's start time could be eventA_start, whereas event B could be called eventB_start, i.e.:
eventA_start = datetime.datetime.now()
The problem is, I don't know the "A" part...the user could choose eventPotato or eventDinosaur. I won't know in advance. I want the name chosen/inputted by the user to be attached to the name for the time that event started.
I have read that the way to do this properly in Python is with use of dictionaries, but I haven't found a reference online that shows how to do it is in a complete way. Any help is appreciated.
_________________________________________________________________
Share life as it happens with the new Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_122007
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071212/a0dd2269/attachment.htm
More information about the Tutor
mailing list