Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]
88888 Dihedral
dihedral88888 at gmail.com
Wed Jun 26 04:18:56 EDT 2013
Michael Torrie於 2013年6月20日星期四UTC+8下午2時01分11秒寫道:
>
> But since the LISP never really got a form beyond S-expressions,
>
> leaving us with lots of parenthesis everywhere, Python wins much as the
>
> Hitchhiker's Guide to the Galaxy wins.
Yep, a list is mutable even it's empty.
But constant integers, floats, strings, and None is immutable.
The variables in a function of python with default
parameters which could be mutable or immutable.
def fun1( x, alist=[]):
alist.append(x*x)
return alist ## valid
def fun2(x, alist=None):
if alist==None: alist=[]
alist.append(x*x)
return alist
# kind of boring to show the name binding mechanism of objects
# in Python in different usages
More information about the Python-list
mailing list