modifying a standard module?

Paul Rubin at nospam.invalid
Fri Feb 12 19:21:30 EST 2016

Ulli Horlacher <framstag at> writes:
>> tarfile.TarFile.extractall = new_extractall
> This is more easy than I could imagined :-) It is in my Python notes,
> now.

This is called "duck punching" or "monkey patching" and sometimes it's
necessary, but it's something of an antipattern since the module could
change under you between versions, and that sort of thing.  If you have
to do it, then fine; but if you have a choice, it's preferable to avoid
that sort of thing.

More information about the Python-list mailing list