Bizarre behavior with mutable default arguments
Istvan Albert
istvan.albert at gmail.com
Sun Dec 30 08:45:46 EST 2007
More information about the Python-list mailing list
Sun Dec 30 08:45:46 EST 2007
- Previous message (by thread): Bizarre behavior with mutable default arguments
- Next message (by thread): Bizarre behavior with mutable default arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Dec 30, 5:23 am, thebjorn <BjornSteinarFjeldPetter... at gmail.com> wrote: > def age(dob, today=datetime.date.today()): > ... > > None of my unit tests caught that one :-) interesting example I can see how it caused some trouble. A quick fix would be to write it: def age(dob, today=datetime.date.today ): and inside the definition invoke it as today() rather than just today. That way it still keeps the original spirit of the definition. i.
- Previous message (by thread): Bizarre behavior with mutable default arguments
- Next message (by thread): Bizarre behavior with mutable default arguments
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list