c[:]()

Grant Edwards grante at visi.com
Fri Jun 1 22:40:56 EDT 2007


On 2007-06-02, Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:
> En Fri, 01 Jun 2007 14:22:29 -0300, Warren Stringer <warren at muse.com>  
> escribió:
>
>> I am not insisting on anything. I use ``c[:]()`` as shorthand
>> way of saying "c() for c in d where d is a container"
>
> I begin to think you are some kind of Eliza experiment with
> Python pseudo-knowledge injected.

I wish I'd said that.

> Anyway, the code below defines a simple "callable" list; it
> just calls each contained item in turn. Don't bother to use
> [:], it won't work.
>
> py> class CallableList(list):
> ...   def __call__(self):
> ...     for item in self:
> ...       item()

Now all we need are user-definable
matched-pair-delimiter-constructors for anonymous user-classed
objects. ;)

-- 
Grant Edwards                   grante             Yow!  I smell a RANCID
                                  at               CORN DOG!
                               visi.com            



More information about the Python-list mailing list