[Python-ideas] Syntax for easy binding __name__, __module__, __qualname__ to arbitrary objects

Markus Unterwaditzer markus at unterwaditzer.net
Tue May 14 12:05:56 CEST 2013


(For some reason my mail software decided not to cc the list)


-------- Original Message --------
From: Markus Unterwaditzer <markus at unterwaditzer.net>
Sent: Tue May 14 07:31:33 CEST 2013
To: Greg Ewing <greg.ewing at canterbury.ac.nz>
Subject: Re: [Python-ideas] Syntax for easy binding __name__, __module__, __qualname__ to arbitrary objects

Greg Ewing <greg.ewing at 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



More information about the Python-ideas mailing list