(The only not unreasonable suggestion in the OP's proposal is to try and
come up with something better than Callable --- we've introduced other
syntax specifically for type annotations, and are likely to do so again.
But **PLEASE** start a new thread for that.)
On Mon, Jul 20, 2020 at 7:37 PM Steven D'Aprano
On Mon, Jul 20, 2020 at 05:16:54PM -0300, Thiago Carvalho D' Ávila wrote:
For beginners, Python functions can cause some pain that boils down to three points that shows some lack of standardization.
1. Function declaration needs keyword `def`:
I have many years of experience helping beginners on mailing lists, and I cannot remember even a single case of anyone being confused by the need to use "def" to declare a function.
I would choose `fun` or even `fn` since they at least resemble the word function.
The keyword "def" is short for "define".
def iter()
is read as "define iter".
In any case, this is a matter of bikeshedding. I think that using "fun" is a terrible choice, because it's not necessarily fun at all:
fun pallative_care_for_the_dying():
but it really doesn't matter. There is zero chance that we will break thirty years of code, tutorials, StackOverflow posts, instructional videos, books etc just to change the colour of this bikeshed from "def" to "fun".
Resemblance of function leads me to my next point.
2. Class name
Again, functions are an exception.
Are they?
We have tuple, not "tup"; list, not "lst", float, not "flt"; bytearray, not "btar"; ValueError, not "VEr".
Abbreviated three or four letter type names are the exception.
But if you have a function as a parameter, your only option is to use Callable. It breaks the rule again having a totally different syntax:
I don't know whether that is the only way, but Callable doesn't just mean function. Callable means any object with a `__call__` method (what C++ refers to as "functor", I believe, not to be confused with Haskell functors, which are completely unrelated), which includes but is not limited to funtions and classes.
With the same goal of removing the pain and making life of Python teachers easier
Making 30 years of tutorials, documentation and books obsolete will not make the life of Python teachers easier.
1. adding `fun` keyword to method definition (maintaining `def` for backwards compatibility);
Having to teach two ways to declare a function instead of one, and answer a thousand questions "What's the difference between def and fun? Which should I use?", doesn't make life easier for teachers.
-- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/JJMS5B... Code of Conduct: http://python.org/psf/codeofconduct/
-- --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-c...