side effects on *some* default parameters

Joe Grossberg jgrossberg at matrixgroup.net
Thu Feb 13 11:31:11 EST 2003


Eric Max Francis writes:
> Because in Python, default argument values are only created once.  The
> FAQ addresses this, and it gets asked about once a week in the group.

OK please allow me to rephrase:

*Why* is this better than the alternative (i.e. default argument values get created every time the method/function is called without the parameter)? 

Is it how all (respected) languages are designed? Is it because of "scope nasties" we'd encounter otherwise? Is it because of how Python is compiled? Or was it an early, arbitrary language design decision that we're stuck with, for better or for worse?

In other words, I'm not asking "Does Python do this?" -- I'm asking "Why does Python do this?"


-- 
----------------------------------------------------------
Joe Grossberg :: Programmer :: jgrossberg at matrixgroup.net
http://www.matrixmaxx.net/ :: Custom Web Solutions and 
Web-Based Association Management Software.







More information about the Python-list mailing list