On Tue, Oct 6, 2020 at 6:47 PM Random832 <random...@fastmail.com> wrote:
> On Tue, Oct 6, 2020, at 02:50, Alperen Keleş wrote: > > Please pardon me if my idea is not making sense or already exists, I'm > > kind of new to developing in Python but I had this idea today and I > > wanted to share it with you. > > > > I think a class type such as "@functionclass" may be helpful for > > creating functions intended to keep a list of methods in a scope. > > > > At the moment, I achieved this via writing "@classmethod" to all my > > functions but I think such a decorator might help clarify intent for > > the reader and ease the programmers' job. > > I think new syntax would be better than a decorator (or a metaclass, which > for some reason never seems to get suggested for these things), because I > think the feature should allow for the functions to directly access each > other from the namespace's scope without requiring an attribute lookup. > A. New syntax is way too high a bar for a questionable feature. Classes full of static or class methods were a pattern at my last employer and it was unpleasant to work with. (Others at the company agreed but it was too late to change.) B. At some point we realized that metaclasses have too much power over subclasses (action at a distance) and we switched to recommending class decorators. Another problem with metaclasses is that it's a pain to combine two different metaclasses. > namespace Foo: > x=1 > def bar(): > pass > def baz() > return bar() + x > That could be done with a function and a function decorator. "Proof left as an exercise for the reader." :-) -- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ILN7PSZ3WLZ2RLP3BIQCD2LK46ZLOGSR/ Code of Conduct: http://python.org/psf/codeofconduct/