[Python-ideas] Ruby-style Blocks in Python Idea (alternative)
Leonardo Santagada
santagada at gmail.com
Tue Mar 10 02:04:52 CET 2009
On Mar 9, 2009, at 9:13 PM, Jan Kanis wrote:
> def callback(param) as result with do_something(with_our(callback),
> other, args):
> print("called back with "+param)
> return foobar(param)
>
>
> this would be equivalent to
>
> def callback(param):
> print("called back with "+param)
> return foobar(param)
>
> result = do_something(with_our(callback), other_args)
Not only the equivalent code looks much cleaner, the only good thing
it actually do (not having to first define a function to then use it)
can be accomplished with a decorator.
Thanks GvR and all that finally shed some light in ruby blocks. I
never understood what was so special about them, now I know it is
nothing really. :)
--
Leonardo Santagada
santagada at gmail.com
More information about the Python-ideas
mailing list