Would Anonymous Functions Help in Learning Programming/Python?

Sean Tierney seanttierney at gmail.com
Sat Sep 22 01:47:17 CEST 2007


Just tell him that "functions are like all  other variables and can
therefore be passed by other functions or returned by other functions.
"

If your friend understands variables and functions and he can't make
the "leap" (and assuming you're right, of course) then your friend
doesn't understand variables and functions.

Happy Friday.

Sean

On 9/21/07, Cristian <super.sgt.pepper at gmail.com> wrote:
> On Sep 21, 3:44 pm, Ron Adam <r... at ronadam.com> wrote:
>
> > 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.
>
> I could discuss name binding but it would be great if Python said this
> itself. After all, you can even bind a module with the foo = bar
> syntax by using __import__ function. If function definitions followed
> the same pattern, I think a beginner would subconsciously (maybe even
> consciously) realize that function names are just like everything
> else. Actually, this would be helpful for many people. If you come
> from a language like Java you're used to thinking of attributes and
> methods as living in different namespaces. I think a new syntax will
> encourage seasoned programmers think in a more Pythonic way.
>
> Python has done a very good job in easing people into programming. My
> friend doesn't come to me very often because the syntax is clear and
> simple and the builtin datatypes allow you to do so much. My goal is
> that I would never have to explain to him about name binding; that
> he'd pick it up by learning the language on his own. He's learned
> lists, dictionaries and even some OOP without me. I don't think name
> binding would be a stretch.
>
> > 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.
>
> I think this isn't the most intuitive way of approaching first order
> functions. It's true that if a function can return another function
> then a function must be first order (i.e., it's just like any other
> variable), but that seems almost backwards to me. I think it would
> make more sense to have beginners _know_ that functions are like all

> other variables and can therefore be passed by other functions or
> returned by other functions. That I think would be better accomplished
> if they define functions the same way you would define other variables
> that you know can be passed and returned.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Sean Tierney



More information about the Python-list mailing list