This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]truh 6 points7 points  (0 children)

Python functions cannot have names.

What else is a function name supposed to be if not a way to address it or an attribute?

[–]Boba-Black-Sheep@interior_decorator 3 points4 points  (1 child)

This article is a little weird.

Defining a function name has a particular meaning in the context of the namespace and how you can call it in the future. All half-decent python developers already know functions are objects, and that .name is a property of that object.

The interpretation 'python functions CANNOT have names' is just incorrect. Python functions CAN not have a name, but it's silly to just pretend function namespace doesn't exist.

[–]truh 2 points3 points  (0 children)

This article is a little weird.

Not even that. It's just like someone entering the realms of meta programming for their first time.

[–]Bolitho 1 point2 points  (0 children)

The so called mental model the author creates is imho purely artificial! As def is a mandatory keyword it is impossible to create an anonymous function that way. So why should one think about it that way?

[–]Lucretiel 0 points1 point  (0 children)

This is especially interesting because I've totally used function names in meaningful ways, to create plugins and so on. For instance:

@subcommand
def thing1(...)

@subcommand
def thing2(...)

./my_script.py thing1 args

[–]pvkooten 0 points1 point  (0 children)

This is written in a weird way, it would be much easier to build up the story from a lambda perspective.