On 16 Apr 2005 23:43:03 -0700, "Kay Schluehr" <[EMAIL PROTECTED]> wrote:
> >Robert Brewer wrote: >> Bengt Richter wrote: >> > The '::' unary suite operator should return an ordered dict >> > subtype representing the bindings >> >> Why ordered? > >Because You can't otherwise guarantee to feed optional argument >parameters in a correct way. > >Example: > >x = property(*seq) where: > seq = (item[1] for item in :: > def get_x(): > return self.__x > def set_x(value): > self.__x = value > del_x = None > doc = "I'm the 'x' property." ) > >This statement would not work if the result of '::' ( considered as an >"ordered dict" ) would return simply a dict because the order of the >input parameters matters. > 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()) Or eliminating parens by using dedent to end the :: suite: 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()) Regards, Bengt Richter -- http://mail.python.org/mailman/listinfo/python-list