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

2017-02-12 Thread Joao S. O. Bueno
On 13 February 2017 at 00:55, Steven D'Aprano wrote: > On Sun, Feb 12, 2017 at 05:01:58PM -0200, Joao S. O. Bueno wrote: > >> You realize now that if we accept this change, and given your example, >> any "well behaved" Python code with markup will in a couple months >> required to be like >> >> c

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

2017-02-12 Thread Steven D'Aprano
On Sun, Feb 12, 2017 at 05:01:58PM -0200, Joao S. O. Bueno wrote: > You realize now that if we accept this change, and given your example, > any "well behaved" Python code with markup will in a couple months > required to be like > > class MyClass: > """Docstring.""" > > def MyClass.__ini

Re: [Python-ideas] site.py uses os.sep to determine platform

2017-02-12 Thread Nick Coghlan
On 12 February 2017 at 16:05, Steve Dower wrote: > It depends on what the code beneath the if is doing. "Windows" may be a > shorthand for "uses backslash", in which case the check is correct. In this case, it's to decide whether the default way of entering EOF at the terminal is by pressing Ctrl

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

2017-02-12 Thread Nick Coghlan
On 12 February 2017 at 22:29, Nick Coghlan wrote: > However, even with that, I'm still only +0 on the idea - if folks > really want it, `types.new_class` can already be used to creatively to > address most of these things, and it's not exactly a problem that > comes up very often in practice. I'l

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

2017-02-12 Thread Nick Coghlan
On 12 February 2017 at 12:38, Paul Moore wrote: > On 12 February 2017 at 04:37, Steven D'Aprano wrote: >>> Making a dedicated syntax or decorator for patching is saying that we >>> (the language) think you should do it. >> >> We already have that syntax: >> >> anything.name = thing > > And the po

Re: [Python-ideas] site.py uses os.sep to determine platform

2017-02-12 Thread Random832
On Sun, Feb 12, 2017, at 07:26, Alex Walters wrote: > On august 7th, 1998, Guido committed > https://github.com/python/cpython/commit/d89fa0c5761254c970af72e5abcea420fd2 > 3e893 to python, adding the quit() and exit() built-ins. He decided to > determine the platform python was running on by check

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

2017-02-12 Thread Joao S. O. Bueno
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]: > ... > > This is useful since you can't refer the class i

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

2017-02-12 Thread David Mertz
Oh, I probably want `return fn` inside my inner decorator. Otherwise, the defined name gets bound to None in the global scope. I'm not sure, maybe that's better... but most likely we should leave the name for other users. I just wrote it without testing. On Sun, Feb 12, 2017 at 10:19 AM, David M

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

2017-02-12 Thread David Mertz
> > Attaching to the instance is fine too. But I prefer the current spelling > so far: > > > my_menu1 = Menu(['Pizza', 'Cake', 'Pasta']) > > my_menu2 = Menu(...) > > > def callback1(self, ...): > ... > def callback2(self, ...): > ... > > my_menu1.callback = callback2 > > my_menu2.callback

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

2017-02-12 Thread Mark E. Haase
On Sun, Feb 12, 2017 at 11:51 AM, Markus Meskanen wrote: > > 2. To register callbacks to objects, i.e. plain out set an attribute for > an instance. I've used the menu example above: > > class Menu: > def __init__(self, items=None, select_callback=None): > self.items = items if i

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

2017-02-12 Thread Markus Meskanen
I think the proposal, so far, seems to confuse two separate things. One is attaching a method to a class after definition. The second is attaching a method to an instance after creation. Or at least it is unclear to me which of those is the intention, since both seem to occur in the examples. Or

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

2017-02-12 Thread Paul Moore
On 12 February 2017 at 16:51, Markus Meskanen wrote: >> I will say, though, that you're right that we've over-reacted a bit to >> the monkeypatching use case. Although maybe that's because no-one can >> think of many *other* use cases that they'd need the new syntax for >> :-) > Hi Paul, I believ

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

2017-02-12 Thread David Mertz
I think the proposal, so far, seems to confuse two separate things. One is attaching a method to a class after definition. The second is attaching a method to an instance after creation. Or at least it is unclear to me which of those is the intention, since both seem to occur in the examples. Or

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

2017-02-12 Thread Markus Meskanen
I will say, though, that you're right that we've over-reacted a bit to the monkeypatching use case. Although maybe that's because no-one can think of many *other* use cases that they'd need the new syntax for :-) Paul Hi Paul, I believe at least two other use cases than monkey patching have been

Re: [Python-ideas] site.py uses os.sep to determine platform

2017-02-12 Thread Stephan Houben
Well to be pedantic, the code is obviously wrong since it assumes EOF is generated by ctrl-D, but the user could have changed that with stty. It should query the terminal settings instead... Yeah I know, people who do that don't need the message. Op 12 feb. 2017 4:26 p.m. schreef "Steve Dower" :

Re: [Python-ideas] site.py uses os.sep to determine platform

2017-02-12 Thread Steve Dower
It depends on what the code beneath the if is doing. "Windows" may be a shorthand for "uses backslash", in which case the check is correct. We should certainly match the check to the intent, but we need to determine the intent first. Cheers, Steve Top-posted from my Windows Phone -Origina

Re: [Python-ideas] site.py uses os.sep to determine platform

2017-02-12 Thread Oleg Broytman
On Sun, Feb 12, 2017 at 07:26:29AM -0500, Alex Walters wrote: > Is there any reason not to change... Do not change things that work for the sake of a change. Isn't it a good reason? Oleg. -- Oleg Broytmanhttp://phdru.name/p...@phdru.name Programmers d

[Python-ideas] site.py uses os.sep to determine platform

2017-02-12 Thread Alex Walters
On august 7th, 1998, Guido committed https://github.com/python/cpython/commit/d89fa0c5761254c970af72e5abcea420fd2 3e893 to python, adding the quit() and exit() built-ins. He decided to determine the platform python was running on by checking os.sep. I don't understand the rationale behind this ch

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

2017-02-12 Thread Paul Moore
On 12 February 2017 at 04:37, Steven D'Aprano wrote: >> Making a dedicated syntax or decorator for patching is saying that we >> (the language) think you should do it. > > We already have that syntax: > > anything.name = thing And the point here is that we don't need to extend def, because we alr

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

2017-02-12 Thread Steven D'Aprano
On Sun, Feb 12, 2017 at 03:50:03PM +1100, Chris Angelico wrote: > >>def foo(x)[5](y, z): > >> ... [...] > > Forget the parser. I know *I* can't cope with that. > > > > *wink* > > So you think the language should prevent silly assignments? On a case-by-case basis, of course. > >>> stu