Re: [Python-ideas] Syntax for easy binding __name__, __module__, __qualname__ to arbitrary objects
(For some reason my mail software decided not to cc the list) -------- Original Message -------- From: Markus Unterwaditzer <markus@unterwaditzer.net> Sent: Tue May 14 07:31:33 CEST 2013 To: Greg Ewing <greg.ewing@canterbury.ac.nz> Subject: Re: [Python-ideas] Syntax for easy binding __name__, __module__, __qualname__ to arbitrary objects Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
I'm not entirely happy with the current proposal:
def name = expr
because it doesn't fully entwine. The expr can be a constructor, but doesn't have to be, and even when it is, the construction occurs separately from the assignment. Also, it looks like an ordinary assignment with 'def' stuck in front, which, as Guido points out, seems somewhat random.
I don't agree with that, i think it's good the proposed syntax looks similar to an assignment, as the feature is clearly related to assignments.
I'd like to propose something a bit different:
def name as expr(arg, ...)
which would expand to something like
name = expr(arg, ..., __name__ = 'name', __module__ = 'module')
To me that implies that the __init__ method of a class has to implement explicit support for this feature, and that there's no way to make a standard implementation for object. I like the proposed __def__ method much more. -- Markus
participants (1)
-
Markus Unterwaditzer