On Tue, Oct 6, 2020 at 6:47 PM Random832 <random832@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)