Would Anonymous Functions Help in Learning Programming/Python?

Ron Adam rrr at ronadam.com
Fri Sep 21 18:44:39 EDT 2007



Cristian wrote:
> My hope is to subtly reinforce the notion that functions are data
> and can be passed around. The current function declaration doesn't
> help with this. Creating a function and assigning it to a name is
> exactly what Python does, why not have it come out in the syntax? It's
> not necessary, yes, but I think it would be helpful for teaching
> purposes.

I think key may be to discuss names and name binding with your friend.  How 
a name is not the object it self, like a variable is in other languages. 
For example show him how an object can have more than one name.  And discus 
how names can be bound to nearly anything, including classes and functions.


> Again, it's not necessary as much as it's more intuitive and obvious
> what's going on. This helps a beginner sort out the process from the
> syntax without taking it on faith. They can see the class declaration
> and see "I'm defining just another attribute to this class only this
> time it happens to be method".
> 
> There is nothing functionally lacking in Python. I'm just curious if
> there's anything Python can do syntax-wise to help a person better
> grasp programming ideas and Python's inner workings.

You could also discus factory functions with him.  Once he gets that a 
function can return another function, then it won't be so much of a leap 
for a function to take a function as an argument.

Of course he'll figure out all this sooner or later anyway.  You can't be 
an engineer without a fair amount of brain cells committed to processing 
abstract concepts.

Cheers,
   Ron




More information about the Python-list mailing list