[Tutor] "Pointer" to a function? Storing a function as an object property? Passing arguments by value/by reference?

wesley chun wescpy at gmail.com
Fri Jan 16 19:30:28 CET 2009


> All Python values are references, so you are essentially storing a
> pointer to the function object within the problem. Python assignment
> does not copy. This is a fundamental concept of Python that often
> confuses newbies, it is worth taking some time to understand it
> correctly. My explanation is here:
> http://personalpages.tds.net/~kent37/kk/00012.html


inside kent's post is an(other) article by fredrik lundh that may be
difficult to see during reading so i want to post it so you don't miss
it:
http://effbot.org/zone/call-by-object.htm

in my training courses, when people ask if Python is
"call-by-reference" or "call-by-value," i tell them it's neither...
*and* both, then proceed to show them what i mean. this topic is
definitely a place where beginners trip up, and it is also where you
begin your long road to maturity as a Python programmer. remember,
Python places an strong emphasis on objects, and in this particular
case, what happens depends on whether an object allows for
modification (mutability).

hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
    http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list