Turn procedure calls into statements? (Re: Code block literals)
Greg Ewing (using news.cis.dfn.de)
g2h5dqi002 at sneakemail.com
Sun Oct 12 22:12:42 EDT 2003
Dave Benjamin wrote:
> Here's my non-PEP for such a feature:
>
> return { |x, y|
> print x
> print y
> }
This is scary! Some years ago I devised a language called "P" that
was translated into Postscript. Its parameterised code blocks looked
EXACTLY like that!
I wouldn't like to see this in Python, though -- it doesn't quite
look Pythonic enough, somehow.
Maybe instead of trying to find a way of shoehorning a compound
statement into an expression, we should be trying to find a way
of writing a procedure call, which would normally be an expression,
as a statement... maybe something like
with_directory "/foo/blarg" do:
print os.listdir(".")
which would be equivalent to
def _somefunc():
print os.listdir(".")
with_directory("/foo/blarg", do = _somefunc)
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list