Boštjan Mejak writes:

 > ***
 > What if we could define functions (that don't have any parameters) like this:
 > 
 > def my_function:
 >     pass
 > 
 > ***
 > Is that a possible scenario at this point, or even desirable?

I'm sure it's possible, but the argument lists are very different in
nature.  (1) The superclasses optionally passed to class are actual
classes and have no necessary relation to the class body, while the
identifiers passed to def are formal arguments which declare their use
to the function body.  (2) object is always an implied superclass, so
"class Foo():" doesn't mean "no superclass", whereas "def foo():"
*does* mean "no arguments."  So the analogy doesn't really stand up.

It's not necessarily undesirable, but what benefit is there other than
saving a couple of keystrokes?  I don't see how

    def myfunction:
        pass

is more readable than

    def myfunction():
        pass

Python is strongly conservative about these things; this is unlikely
to get any uptake unless you can show a benefit bigger than saving two
keystrokes on a relatively uncommon construct.  In the case of class,
on the other hand, requiring "(object)" is a fair amount of clutter
that is never necessary because object is always present as the root
of the class hierarchy.  It might be more consistent to require the
parentheses, but that's not obvious to me.

Steve


_______________________________________________
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/ZQV7NECJZFXHJWNSTJAKDNL2R2XLFZXT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to