Python: default argument blunders

A few minutes ago a friend sent me the following code, and told me its misbehaving: def foo(l=[]): l.append(“hello!”) print(l) foo() foo() Instead of printing [“hello”] twice, it printed [“hello”, “hello”]. Any ideas why? what’s going on? I’ll… Read more


Python text for journeyman programmer

This book provides a reader with a holistic and in-depth knowledge of the Python language. It explains how methods and functions are related, how sequences can be created elegantly, the tools for functional programming, how user defined objects can be no ...

Read more »