[Python-ideas] Fwd: Define a method or function attribute outside of a class with the dot operator
rosuav at gmail.com
Fri Feb 10 07:12:53 EST 2017
On Fri, Feb 10, 2017 at 11:02 PM, Thomas Kluyver <thomas at kluyver.me.uk> wrote:
> On Fri, Feb 10, 2017, at 11:05 AM, Chris Angelico wrote:
>> * What would the __name__ be? In "def ham.spam():", is the name "spam"
>> or "ham.spam"? Or say you have "def x():" - is the name "x" or
>> something else?
> I'd say 'spam' in the first case, and a special value like '<unnamed
> function>' in the latter. You already can't rely on __name__ being a
> usable name in arbitrary callables:
> x = lambda: 0
> x.__name__ == '<lambda>'
And this is exactly why this wants a PEP - to collect decisions and
arguments on all of these bikesheds.
More information about the Python-ideas