On Wed, Aug 17, 2011 at 6:38 PM, Seebs <usenet-nos...@seebs.net> wrote: > I may have been unclear about jumping topics; that comment was about > monkey-patching, not about shadowing. >
Ah, apologies. Monkey-patching is a way of using the middle of a stack of code without using what's below it. If everything is statically linked, then every function does exactly what it was written to do and no more; if it accepts a file object as an argument, you could give it some other file-like object, but that's all. However, if the function was written to use print() and you don't want it to print to the screen, what do you do? Obviously it's your responsibility to ensure that your replacement is 100% equivalent in the required functionality, but it's a great flexibility to simply change the meaning of "print"; the alternative is to copy and paste the code, make one change (or even no change at all, if your replacement print() is a global), and run that. As Ethan posted while I was typing this, you're allowed to do it, but you just need to have a good reason for it. I like to explain/justify myself in comments when these things crop up in my code. ChrisA -- http://mail.python.org/mailman/listinfo/python-list