Brian Sabbey wrote:Here is a pre-PEP for what I call "suite-based keyword arguments". The mechanism described here is intended to act as a complement to thunks. Please let me know what you think.
Suite-Based Keyword Arguments -----------------------------
Passing complicated arguments to functions is currently awkward in Python. For example, the typical way to define a class property winds up polluting the class's namespace with the property's get/set methods. By allowing keyword arguments to be defined in a suite following a function call, complicated arguments can be passed in a cleaner, easier way.
Examples ========
Using suite-based keyword arguments, the code
f(x = 1)
is equivalent to
f(): x = 1
Pretty cool, but it interferes with current suites.
How would you write
if f(x=1): print "yes"
using suite-based keyword args?
Reinhold
You wouldn't be able to use suite keywords in that situation. Also, one would not be able to use suite keywords when there is more than one function call on the same line:
y = f()*g(): x = 1 # ?? not allowed
There is only so much suites can do. Cases in which you want to do both are probably far enough between that it seems acceptable to me to require two suites:
t = f(): x = 1 if t: y = 1
In general, I think that anything more than just a function call with an optional assignment should be disallowed:
y = [f()]: # ? probably shouldn't be allowed x = 1
-Brian -- http://mail.python.org/mailman/listinfo/python-list