Re: [Tutor] user-given variable names for objects

2008-02-28 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Perhaps even nicer: [key for key, evtime in eventData.iteritems() if evtime < time.time()] This way the dictionary iterates over key, value tuples. Andreas Tiger12506 wrote: | I may sound like a know-it-all, but dictionaries *are* iterators. | | [a

Re: [Tutor] user-given variable names for objects

2007-12-15 Thread Kent Johnson
Tiger12506 wrote: >> Mmm, to nit-pick a little, dictionaries are iterables, not iterators. They >> don't have a next() method. > > I'm a little fuzzy on the details of that, I will have to look over some > reference material again. An iterable is something that produces an iterator when you cal

Re: [Tutor] user-given variable names for objects

2007-12-15 Thread Tiger12506
> Mmm, to nit-pick a little, dictionaries are iterables, not iterators. They > don't have a next() method. I'm a little fuzzy on the details of that, I will have to look over some reference material again. >> [a for a in eventData if eventData[a] < time.time()] >> >> This is more efficient. The

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Luke Paireepinart
On Dec 13, 2008 3:12 PM, Tiger12506 <[EMAIL PROTECTED]> wrote: > I may sound like a know-it-all, but dictionaries *are* iterators. I'm used to that from you :P > > [a for a in eventData if eventData[a] < time.time()] > > This is more efficient. The keys method creates a list in memory first and

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Luke Paireepinart
> > > By the way, what was the purpose of the line with > > time.sleep(1) > > It pauses for 1 second. But i'm not sure why he wanted a pause! :-) > Just because it would dump a bunch of stuff to the screen really quickly that you couldn't read as soon as some events expired. ___

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Kent Johnson
Tiger12506 wrote: > I may sound like a know-it-all, but dictionaries *are* iterators. Mmm, to nit-pick a little, dictionaries are iterables, not iterators. They don't have a next() method. > [a for a in eventData if eventData[a] < time.time()] > > This is more efficient. The keys method creates

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Tiger12506
I may sound like a know-it-all, but dictionaries *are* iterators. [a for a in eventData if eventData[a] < time.time()] This is more efficient. The keys method creates a list in memory first and then it iterates over it. Unnecessary. > > "Che M" <[EMAIL PROTECTED]> wrote > >> Although I was not

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Alan Gauld
"Che M" <[EMAIL PROTECTED]> wrote > Although I was not familiar with what you can do with a list such > as you did here: > [a for a in eventData.keys() if eventData[a] < time.time()] This is known as a list comprehension (and is described in the Functional Programming topic of my tutorial - o

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Che M
> Date: Thu, 13 Dec 2007 01:58:10 -0600 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > CC: tutor@python.org > Subject: Re: [Tutor] user-given variable names for objects > > Che M wrote: > > I'm sure this is a classic beginner's topic, and I've re

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Che M
> To: tutor@python.org > From: [EMAIL PROTECTED] > Date: Thu, 13 Dec 2007 07:53:36 + > Subject: Re: [Tutor] user-given variable names for objects > > > "Che M" <[EMAIL PROTECTED]> wrote > > > I'm sure this is a classic beginner's t

Re: [Tutor] user-given variable names for objects

2007-12-12 Thread Luke Paireepinart
Che M wrote: > 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. Yes, this comes up quite a bit. > In pa

Re: [Tutor] user-given variable names for objects

2007-12-12 Thread Alan Gauld
"Che M" <[EMAIL PROTECTED]> wrote > I'm sure this is a classic beginner's topic, Indeed it is, it comes up about once a month or more! > I want to assign names to objects based on what a > user inputs so that I can later keep track of them. This is almost never what you want to do, for pre

[Tutor] user-given variable names for objects

2007-12-12 Thread Che M
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 gett