Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-14 Thread nate lust
All, I must say It is still exciting to be at a point of getting an official declaration on a topic from Guido. We thank you for your time and feedback. It has been a good experience and hope to be able to contribute in some other way in the future. Nate and Pim On Wed, Sep 14, 2016 at 12:30 PM

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-14 Thread Guido van Rossum
There shall be no standard syntax for monkey-patching. Decorators are fine. I recommend putting a monkey-patching package on PyPI and see if people use it. Maybe eventually it can be in the stdlib but I really don't want to encourage this idiom (even if it's sometimes useful). You should always

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-14 Thread Pim Schellart
Dear All, Thank you for your feedback! While we think the decorator solution is not as writable, readable or discoverable as our proposed syntax we understand the desire to discourage a potential paradigm switch to `open classes’. We recognise that in many cases refactoring the code to

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-14 Thread Nick Coghlan
On 14 September 2016 at 05:46, Ralph Broenink wrote: > Hi all, > > On Tue, 13 Sep 2016 at 18:30 Chris Angelico wrote: >> >> Did you know that you can actually abuse decorators to do this with >> existing syntax? Check out this collection of evil uses of

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Greg Ewing
Chris Angelico wrote: Yes. You could tweak that by looking at cls.__module__ and grab it from sys.modules, but I kept the example simple. However, I would NOT use the standard name lookup mechanism. Most classes in builtins won't let you monkeypatch them anyway, so I'm not sure it's worth the

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Chris Angelico
On Wed, Sep 14, 2016 at 9:35 AM, Greg Ewing wrote: > Chris Angelico wrote: > >> It's a little bit magical, in that it looks up the original class >> using globals(); > > > The way you've written it, monkeypatch() will only work > if you call it from the module it's

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Ethan Furman
On 09/13/2016 09:29 AM, Chris Angelico wrote: On Wed, Sep 14, 2016 at 2:16 AM, Pim Schellart wrote: A well-written PEP that looked very interesting. https://github.com/Rosuav/Decorators/blob/master/evil.py @monkeypatch class A: x = 5 def foo(self): pass def

Re: [Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Chris Angelico
On Wed, Sep 14, 2016 at 2:16 AM, Pim Schellart wrote: > Semantics > = > > The following two snippets are semantically identical:: > > continue class A: > x = 5 > def foo(self): > pass > def bar(self): > pass > > def

[Python-ideas] New Python syntax for continuing definitions for existing classes

2016-09-13 Thread Pim Schellart
Dear Python Developers, we have a potential idea for enhancing Python. Below you will find what the PEP might look like. A reference implementation has been written and will be posted in a follow up message. We are look forward to hearing your feedback and ideas. Kind regards, Pim Schellart &