c[:]()

Warren Stringer warren at muse.com
Thu May 31 10:59:35 EDT 2007


Hey Marc,

> > [d() for d in c]
> 
> If you are using the list comprehension just for the side effect of
> calling `d` then consider this bad style.  You are building a list of
> `None` objects just to have a "cool" one liner then.

Yep, you're right  

> for func in funcs:
>     func()
> 
> Because it is explicit and readable and matches the english description
> "for every function in functions: call that function" very closely while a
> list comprehension or your "perlish" line noise is much more magic to
> explain and harder to remember.

Hmmmm... the reason what I use the list comprehension was the description
"call that thing for every thing in those things" The first time I something
saw this I though, in my C befuddled head 'huh? that's backwards!'  But,
then the more I thought about it I recall that this is how some people
speak.

Still  I prefer

funcs[:]()

Because, I can describe it in English as "call everything that funcs has"

(BTW, I have yet to write my first line of Perl. It that good thing or a bad
thing?)




More information about the Python-list mailing list