pre-PEP: Suite-Based Keywords - syntax proposal

Kay Schluehr kay.schluehr at gmx.net
Sun Apr 17 12:27:34 EDT 2005


> Exactly. Except the above example is from the day-old-bread
items-tuple-returning version of :: ;-)
> And with an ordered dict subtype there is no need for the generator
expression either,
> since there is a values method for dicts (which in the subtype would
preserve order). E.g.,
>
>  x = property(*seq) where:
>              seq = (::
>                  def get_x():
>                      return self.__x
>                  def set_x(value):
>                      self.__x = value
>                  del_x = None
>                  doc   = "I'm the 'x' property." ).values())
>
> Or more directly:
>
>  x = property(*(::
>                  def get_x():
>                      return self.__x
>                  def set_x(value):
>                      self.__x = value
>                  del_x = None
>                  doc   = "I'm the 'x' property." ).values())

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."


Put definitions into a list:

l = list(*args) where args:
        def fget(self):
            return self.__x
        doc = "I'm the 'x' property."


Nest suites:

x = property(*args) where args:
        t = tuple(*t) where t:
            def fget(self):
                return self.__x
            fset = None
            fdel = None
            doc = "I'm the 'x' property."


Evaluate conditions:

if f(*args)==1 where args:
   x = 1
   y = 2

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.
   
Regards,
Kay




More information about the Python-list mailing list