[docs] [issue28681] About function renaming in the tutorial

Terry J. Reedy report at bugs.python.org
Fri Nov 18 13:25:26 EST 2016


Terry J. Reedy added the comment:

It took me a moment to realize that 'value of the function name' meant 'the function object associated with the name'.  I think David's rewrite is a substantial improvement.  I would just change the end 'can be used as a function' to 'can be used to access the function.'

'Renaming' is wrong to me because it implies invalidation of the previous name. 'Alternate name' is more accurate.

I agree that 'alias' is better, but also that it is a bit problematical*.  'Alias' is distinct from 'legal name'. The closest analogy to 'legal name' is 'definition name' (.__name__ attribute).  But definition names are distinct from bound names, only some objects have definition names, and when they do, they can be renamed if and only if the object is coded in Python. 

I don't understand the relevance of the middle sentence
   "The interpreter recognizes the object pointed to by that
   name as a user-defined function."
All objects can be given multiple names.  In this context, the difference between C and Python coded names is whether the .__name__ attribute can be rebound, and that attribute is not part of the discussion here.  The paragraph introduces this code example, which has nothing to do with .__name__.

   >>> fib
   <function fib at 10042ed0>
   >>> f = fib
   >>> f(100)
   0 1 1 2 3 5 8 13 21 34 55 89

(* Steven, I would say that both 'x' and 'y' in your example are aliases for the int 1.  But I understand the other viewpoint.)

----------
nosy: +terry.reedy
stage:  -> needs patch
versions:  -Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28681>
_______________________________________


More information about the docs mailing list