c[:]()

Jerry Hill malaclypse2 at gmail.com
Fri Jun 1 19:36:39 CEST 2007


On 6/1/07, Warren Stringer <warren at muse.com> wrote:
> > And that your
> > insisting on ``c[:]()`` instead of just ``c()`` seems to indicate you want
> > a change that is quite surprising.  It would mean that a slice of a list
> > returns an other type with the __call__ method implemented.
>
> I am not insisting on anything. I use ``c[:]()`` as shorthand way of saying
> "c() for c in d where d is a container"

The problem people are having with that is that c[:]() *already* means
something in python, and it doesn't mean "c() for c in d where d is a
container".  In today's python c[:]() means "return a slice of object
c, then call that slice".  Since most container objects don't have a
__call__() method, it doesn't do what you want, but it is currently
valid syntax.

-- 
Jerry



More information about the Python-list mailing list