list comprehensions whats happening here

Carlos Ribeiro cribeiro at mail.inet.com.br
Sat Apr 14 10:06:46 EDT 2001


At 22:14 13/04/01 -0400, Terry Reedy wrote:
>[[0,j] for j in ('a','b','c')] is much cleaner and faster.  Methinks
>turning a constant into a pseudovariable is the wrong way to go.

Ouch. I really messed up with this one. I apologize for wasting bandwidth 
when a *much* better idiom is already available. Please erase all that I 
said before :-) I assumed (wrongly) that I could not put a constant value 
on the list constructor - however, I forgot that constants are objects in 
Python as any other value <wink>. Coming from a C/Pascal background this is 
easily explained...


Carlos Ribeiro






More information about the Python-list mailing list