Re: [Python-ideas] Define a method or function attribute outside of a class with the dot operator

2017-02-13 Thread David Mertz
On Mon, Feb 13, 2017 at 5:48 PM, Steven D'Aprano wrote: > # the clean proposed way: > def instance.method(self): # or MyClass.method > ... > > But I don't think that we can reasonably argue that the suggested syntax > isn't a clear, non-trivial win over the status quo, not unless we're > als

Re: [Python-ideas] Define a method or function attribute outside of a class with the dot operator

2017-02-13 Thread Steven D'Aprano
On Fri, Feb 10, 2017 at 09:05:49PM -0500, Terry Reedy wrote: > >def foo(self): > >pass > >Foo.foo = foo > > > >Becomes: > > > >def Foo.foo(self): > >pass > > Saving about 10 keystrokes is close to trivial. The same argument can be made for @decorator syntax. And, if

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread Steven D'Aprano
On Sun, Feb 12, 2017 at 10:29:10PM +0100, Nick Coghlan wrote: [...] > Method injection is most attractive to me as a potential alternative > to mixin classes that has fewer runtime side effects by moving more of > the work to class definition time. > > More philosophically though, it offends my la

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread Steven D'Aprano
On Mon, Feb 13, 2017 at 11:50:09AM -0800, Matt Gilson wrote: > For whatever weight my opinion holds, I'm +0 on this one. In my > estimation, in an ideal world it seems like: > > class Foo(object): > def bar(self): > """Bar!""" > > > # Identical to: > > class F

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread Steven D'Aprano
On Mon, Feb 13, 2017 at 02:32:33PM -0500, Joseph Hackman wrote: > Generally speaking, I'm +1 on this idea, I think it would make code > more readable, especially for tools like IDEs. > > I just wanted to ask: can someone point me to the reason Python > doesn't support referencing a class inside

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread M.-A. Lemburg
On 13.02.2017 20:32, Joseph Hackman wrote: > I just wanted to ask: can someone point me to the reason Python doesn't > support referencing a class inside it's own definition? It seems like that > would solve some of the cases discussed here, and with Type hinting that > seems like something that

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread Matt Gilson
For whatever weight my opinion holds, I'm +0 on this one. In my estimation, in an ideal world it seems like: class Foo(object): def bar(self): """Bar!""" # Identical to: class Foo(object): pass def Foo.bar(self): """Bar!""" But I think that's goi

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread Joseph Hackman
Generally speaking, I'm +1 on this idea, I think it would make code more readable, especially for tools like IDEs. I just wanted to ask: can someone point me to the reason Python doesn't support referencing a class inside it's own definition? It seems like that would solve some of the cases di

Re: [Python-ideas] Fwd: Define a method or function attributeoutsideof a class with the dot operator

2017-02-13 Thread Kyle Lahnakoski
On 2017-02-12 14:01, Joao S. O. Bueno wrote: > On 12 February 2017 at 14:51, Markus Meskanen > wrote: >> 1. Allowing the class to be used in the method's header, f.e. for typing and >> decorators: >> >> @decorate(MyClass) >> def MyClass.method(self, other: MyClass) -> List[MyClass]: >>

[Python-ideas] Python package index: query and rating

2017-02-13 Thread George Fischhof
Hi There, I several times found that it is quite difficult to find an appropriate library in package index. I have two ides to improve the package index: 1.) Query like in a webshop: checkboxes should use to select from attributes. (topic, environment, category etc) It would br good to put a "do