c[:]()

Grant Edwards grante at visi.com
Thu May 31 11:54:41 EDT 2007


On 2007-05-31, Warren Stringer <warren at muse.com> wrote:

>> > 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()
>
> Oh hey Grant, yes, I misunderstood your question for a bit. I
> thought you meant the difference between List comprehension
> [...] and generator expressions (...) where the first returns
> the whole list and the second iterates the whole list. 
>
> But, yes, good point if I was only using [:]. For more
> expressiveness,

How is it more expressive?  In the context you're concerned
with, c[:] is the exactly same thing as c.  You seem to be
worried about saving keystrokes, yet you use c[:] instead of c.

It's like having an integer variable i and using ((i+0)*1)
instead of i.

-- 
Grant Edwards                   grante             Yow! I want to read my new
                                  at               poem about pork brains and
                               visi.com            outer space ...



More information about the Python-list mailing list