I was battling with some code that used instanceof() in python. I don't where that's a built-in (I suspect jython), but it doesn't work on my python 2.4.3. While I was wondering about this problem, I tried something outlandish and it worked. But before I actually explain what I did, take a closer look at this module (x.py).
def identity(h): return h def coolfunc(p): return identity(p)
That was pretty standard code, right ? Now, to use/abuse this module in y.py.
import x print x.coolfunc("Hello World !") x.identity = lambda x : 42; print x.coolfunc("What is 21 + 21 ?")
As you can probably guess, I can override (uhh.., pollute) x.identity with my own functions, which opens up a solution to my original problem. Pretty simple, now that I think of it.
othermodule.instanceof = lambda x,y : type(x) == y
I hope this has made your friday a little bit more surreal :)--
Talent to endure stems from the ignorance of alternatives.
Found this in one of the mailing lists - but this is total fnuk. Please feel free to click on any of the following links - yahoo shit and google shit. Please take a look at your title bar of your browser to understand the true beauty of bi-directional font-rendering :)
I'm sure xoferiF wouldn't violate any trademarks by the Mozilla foundation.--
Drawing on my fine command of language, I said nothing.