c[:]()

Warren Stringer warren at muse.com
Thu May 31 11:09:47 EDT 2007


Cool! Yes. By the way, I've discovered that [] are quite difficult on cell
phones. But periods and parens are easy. So, I'm using your approach for
creating a dot operator for {}
 

> -----Original Message-----
> From: python-list-bounces+warren=muse.com at python.org [mailto:python-list-
> bounces+warren=muse.com at python.org] On Behalf Of Mikael Olofsson
> Sent: Thursday, May 31, 2007 1:52 AM
> To: python-list at python.org
> Subject: Re: c[:]()
> 
> Warren Stringer wrote:
> > I want to call every object in a tupple, like so:
> > [snip examples]
> > Why? Because I want to make Python calls from a cell phone.
> > Every keystroke is precious; even list comprehension is too much.
> 
> If you are going to do this just a few times in your program, I cannot
> help. But: If you want to do it several times, perhaps you have space
> for an initial class definition, like so:
> 
> class CallableList(list):
>     def __call__(self,*args,**kwargs):
>         return [f(*args,**kwargs) for f in self]
> 
> def a(): return 'a called'
> def b(): return 'b called'
> c = CallableList([a,b])()
> 
> You might want to trim the class to fit your needs, perhaps use a
> shorter name, and perhaps you don't need to handle arguments. Can the
> class be placed in a module, so that it only needs to be typed once in
> your application?
> 
> /MiO
> --
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list