[Python-ideas] adding an __exec__ method to context managers?
Ben Finney
ben+python at benfinney.id.au
Tue Oct 13 08:22:05 CEST 2009
Carl Johnson
<cmjohnson.mailinglist at gmail.com> writes:
> Taking a step back, it seems like what you really want is some easy
> way to create callbacks, just like Ruby blocks or the new Objective-C
> blocks. There are a number of ways this could be done:
[…]
Unless I misunderstand one or more of the options you present, you've
omitted the most obvious way under current Python: create a function
using ‘def’ and use the name to refer to that function object.
> Frankly I think this list is going to face proposals for some block
> substitute or another every couple months between now and whenever
> Python finally allows for some more readable way of passing functions
> to other functions.
What is insufficiently readable about::
def foo(spam):
process_wibble(spam)
process_wobble(spam)
return process_warble(spam)
bar(foo)
--
\ “I went to a garage sale. ‘How much for the garage?’ ‘It's not |
`\ for sale.’” —Steven Wright |
_o__) |
Ben Finney
More information about the Python-ideas
mailing list