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

Similar

Eventloop Sidecar in Python

A command pattern that I’ve used in multiple projects is an event-loop sidecar. The sidecar runs on it’s own thread and does asynchronous IO; thereby increasing the responsiveness of the system which could be doing IO/CPU bound work. The application (runn... (more…)

Read more »