D'oh I should've caught that myself.

Thanks.

Fredrik Lundh wrote:
Lowell Kirsh wrote:

On a webpage (see link below) I read that the following 2 forms are not the same and that the second should be avoided. They look the same to me. What's the difference?


def functionF(argString="abc", argList = None):
       if argList is None: argList = []
       ...

def functionF(argString="abc", argList=None):
       argList = argList or []
       ...


"is None" tests for None, "argList or" tests for a false value.  None is
false, but many non-None objects are also false.

"should be avoided" sounds like overly zealous advice to me; use the
latter form if you understand it.

</F>



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to