In article <k2p9da$ktu$1...@r03.glglgl.gl>, Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de> wrote: >Am 11.09.2012 05:46 schrieb Steven D'Aprano: >> >> Good for you. (Sorry, that comes across as more condescending than it is >> intended as.) Monkey-patching often gets used for quick scripts and tiny >> pieces of code because it works. >> >> Just beware that if you extend that technique to larger bodies of code, >> say when using a large framework, or multiple libraries, your experience >> may not be quite so good. Especially if *they* are monkey-patching too, >> as some very large frameworks sometimes do. (Or so I am lead to believe.) > >This sonds like a good use case for a context manager, like the one in >decimal.Context.get_manager().
Note that because get_manager() applies to a specific Context instance it is safe in a threaded application, which is NOT true for monkey-patching modules even with a context manager. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "....Normal is what cuts off your sixth finger and your tail..." --Siobhan -- http://mail.python.org/mailman/listinfo/python-list