I've started working on a PEP for this since most people seem to be for it. Will see how it turns out.
On Fri, Feb 10, 2017 at 2:13 PM, Joao S. O. Bueno <[email protected]> wrote: > I am definetelly -1 to this idea. > > But since you are discussing this seriously, one nice thing is to > recall how Javascript does that: > `function <name> () ` is an expression that returns the created > function, and thus can be assigned to anything on > the left side. > > Of course, that would throw us back to a way of thinking of inline > definition of multiline functions - > which is another requested and unresolved thing in Python. > > (But we might require the `def` statement to still be aligned, at > least style-wise, and require > people to write > > Foo.foo =\ > def (self, ...): ... > > ) > > That said, this possibility in Javascript is the source of severe > inconsistencies in how functions are declared across different > libraries and projects, and IMHO, makes reading (and writting) a real pain. > > (And, as stated above, a two line decorator could make for the patching - > it does not need to have such an ugly name as "monkey_patch" - it > could be just "assign" instead) > > js > -><- > > On 10 February 2017 at 09:51, Steven D'Aprano <[email protected]> wrote: > > On Fri, Feb 10, 2017 at 10:05:30PM +1100, Chris Angelico wrote: > > > >> * What would the __name__ be? In "def ham.spam():", is the name "spam" > >> or "ham.spam"? > > > > "spam" of course, just like it is now: > > > > py> class Ham: > > ... def spam(self): > > ... ... > > ... > > py> > > py> Ham.spam.__name__ > > 'spam' > > > > > > You might be thinking of __qualname__: > > > > py> Ham.spam.__qualname__ > > 'Ham.spam' > > > > > >> Or say you have "def x[0]():" - is the name "x[0]" or > >> something else? > > > > I wouldn't allow that. I feel that "any assignment target at all" is an > > over-generalisation, a case of YAGNI. > > > > It is relatively easy to change our mind and add additional cases in the > > future, but very difficult to remove them if they turn out to be a > > mistake. > > > > My intuition tells me that we should allow : > > > > def name dot name (args): > > > > possibly even more than one dot: > > > > def name dot name dot name ... (args): > > > > > > but no additional cases: > > > > # syntax error > > def spam[0]function(): ... > > > > > > > > > > -- > > Steve > > _______________________________________________ > > Python-ideas mailing list > > [email protected] > > https://mail.python.org/mailman/listinfo/python-ideas > > Code of Conduct: http://python.org/psf/codeofconduct/ > _______________________________________________ > Python-ideas mailing list > [email protected] > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
