-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
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
> 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
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
>
> > 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.
___
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
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
"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
> 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
> 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
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
"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
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
13 matches
Mail list logo