alternating the builtin functions
Peter Hansen
peter at engcorp.com
Sun Oct 19 14:15:36 EDT 2003
"Carlo v. Dango" wrote:
>
> sure, but my version relies on the original one, so I need a way to call
> the original isinstance() from within my isinstance()...
So just keep a reference to it.
'''a module that has your isinstance in it:'''
_builtin_isinstance = isinstance
def carlo_isInstance(foo, bar):
# do some stuff that the original didn't do, then delegate
# to the original
return _builtin_isinstance(foo, bar)
# shadow the builtin name with your own, for the rest of this
# module, if you like
isinstance = carlo_isInstance
Or whatever variation works for you...
Actually, I think all Jp is really saying is don't use the name "isinstance"
for your own... then none of this is an issue. When you want your
version, you just call it. The original stays unperturbed.
-Peter
More information about the Python-list
mailing list