c[:]()
Grant Edwards
grante at visi.com
Thu May 31 10:53:51 EDT 2007
On 2007-05-31, Warren Stringer <warren at muse.com> wrote:
> Oops! guess I should have tested my rather hasty complaint about executable
> containers. This is nice:
>
> def a(): return 'b'
> def b(): print 'polly! wakey wakey'
> c = {}
> c['a'] = b
> c[a()]() #works!
>
>
> c[a()]() is a switch statement with an amorphous selector- very handy in its
> own right. But, using a() as a generator would be more expressive. This
> seems to work:
>
> c = [a,a]
> [d() for d in c]
>
> But that still isn't as simple or as direct as:
>
> c[:]()
Why do you always use a _copy_ of c in your examples? As long
as you're wishing, why not just
c()
--
Grant Edwards grante Yow! I'm meditating on
at the FORMALDEHYDE and the
visi.com ASBESTOS leaking into my
PERSONAL SPACE!!
More information about the Python-list
mailing list