pre-PEP: Suite-Based Keywords
Shane Hathaway
shane at hathawaymix.org
Sat Apr 16 03:06:25 EDT 2005
Kent Johnson wrote:
> Brian Sabbey wrote:
>> Using suite-based keyword arguments, the code
>>
>> f(x = 1)
>>
>> is equivalent to
>>
>> f():
>> x = 1
>
>
> ISTM the syntax is ambiguous. How do you interpret
> if f():
> x = 1
> ?
>
> Is a suite alllowed only when a block could not be introduced in the
> current syntax?
I like this PEP a lot, but your concern is valid. Maybe Brian could
modify the PEP slightly to disambiguate. How about using an ellipsis in
the argument list to signify suite-based keywords? Examples:
f(...):
x = 1
class C(object):
x = property(...):
doc = "I'm the 'x' property."
def fget(self):
return self.__x
def fset(self, value):
self.__x = value
def fdel(self):
del self.__x
d = dict(...):
a = 1
b = 2
Using an ellipsis in a statement that would begin a different kind of
block is illegal and generates a syntax error. Note that this usage
seems to fit well with the definition of "ellipsis".
http://dictionary.reference.com/search?q=ellipsis
Shane
More information about the Python-list
mailing list