pre-PEP: Suite-Based Keywords - syntax proposal

Steven Bethard steven.bethard at gmail.com
Sun Apr 17 22:41:21 EDT 2005


Kay Schluehr wrote:
> Hmmm ... now You eliminate "where" completely in favor for '::'. This
> may be reasonable because '::' is stronger and less context dependent.
> But on the other hand it may be also reasonable to eliminate '::'
> towards a stronger "where" ;)
> 
> x = property(**kw) where kw:
>             doc = "I'm the 'x' property."
>             def fget(self):
>                 return self.__x
> 
> 
> x = property(*args) where args:
>             def fget(self):
>                 return self.__x
>             fset = None
>             fdel = None
>             doc = "I'm the 'x' property."
[snip]
> I think this version is more mainstream syntax ( and without braces and
> additional punctuation ) than the unary prefix operator '::' which
> drops statements into expressions within expressions.

So the object of a "where" is then always an ordered dict?  If so, then 
I guess I like this proposal best so far.

However, it does seem to have the problem that you can't have any 
additional local variables so, for example, list comprehensions are 
probably not usable...

Or can you still drop the argument to "where" and just use the names 
directly?  E.g.:

x = property(fget=fget, doc=doc) where:
     doc = "I'm the 'x' property."
     def fget(self):
         return self.__x

STeVe



More information about the Python-list mailing list