-----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 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 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 - obligatory plug :-) |> |>> I guess .keys() is a built-in method for dictionaries to return a |>> list of all their values, then? |> To be accurate it returns a list of the keys, the values are the |> things you get when you access the dictionary using a key: |> |> value = dictionary[key] |> |> So you can do things like |> |> for key in dictionary.keys(): |> print dictionary[key] |> |>> 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! :-) |> |> Alan G. |> | | _______________________________________________ | Tutor maillist - Tutor@python.org | http://mail.python.org/mailman/listinfo/tutor -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHxneXHJdudm4KnO0RAnl3AJ4m+Uguik+C+1b6gXeaolcOhb0CwQCghNYt Hc1JuP17yefS3vW3tC2HO9I= =sMI9 -----END PGP SIGNATURE----- _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor