pre-PEP: Suite-Based Keywords
Kay Schluehr
kay.schluehr at gmx.net
Sat Apr 16 17:09:49 EDT 2005
Nicolas Fleury wrote:
> Shane Hathaway wrote:
> > 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
>
> I like the ellipsis syntax a lot, it greatly helps the proposal IMHO.
>
> Regards,
> Nicolas
I think the usage of the block is still limited in Shawns answer. Kents
objection can be evaded but Reinhold Birkenfelds remains valid.
The statement
f(...):
x = 1
is still not an expression like f(x=1) is. I think one has to mark
somehow the scope of the suite-based keywords.
In the examples below we can identifiy the expression belonging to f
without ambiguities and restrictions.
f(y=0,..)
.. x = 1
if f(y=2,..) == 1:
.. x = 5
def g(a):
a**2-1
return 8
Note that the colon after f has vanished as expected for a call.
Ciao,
Kay
More information about the Python-list
mailing list