default mutable arguments

Gigs_ gigs at hi.t-com.hr
Thu Feb 8 14:16:09 EST 2007


I read that this is not the same:
if arg is None: arg = []
arg = arg or []


def functionF(argString="abc", argList = None):
         if argList is None: argList = []      # < this
         ...
def functionF(argString="abc", argList=None):
         argList = argList or []               # and this
         ...

Why?


thanks !!!



More information about the Python-list mailing list