> David Hirschfield (DH) wrote:
>DH> Yeah, it definitely seems like having two separate decorators is the
>DH> solution. But the strange thing is that I found this snippet after some
>DH> deep googling, that seems to do something *like* what I want, though I
>DH> don't understand the descript
On Wed, Jul 1, 2009 at 2:14 AM, David Hirschfield wrote:
> Unfortunately that still requires two separate decorators, when I was
> hoping there was a way to determine if I was handed a function or method
> from within the same decorator.
>
> Seems like there really isn't, so two decorators is th
Unfortunately that still requires two separate decorators, when I was
hoping there was a way to determine if I was handed a function or method
from within the same decorator.
Seems like there really isn't, so two decorators is the way to go.
Thanks,
-David
Carl Banks wrote:
On Jun 29, 6:01 pm
On Jun 29, 6:01 pm, David Hirschfield wrote:
> So is there
> a pattern I can follow that will allow me to determine whether the
> objects I'm given are plain functions or belong to a class?
>
> Thanks in advance,
class HomemadeUnboundMethod(object):
def __init__(self,func):
self.fun
I do not like top posting.
Some thoughts in randon order:
Introspection is version-specific.
Call-time introspection is different from definition-time introspection.
Do what is easy and works.
Do not use recipes that depend on version-specific stuff you do not
understand.
Code objects, I believe
On Mon, 29 Jun 2009 18:01:29 -0700, David Hirschfield wrote:
> I'm having a little problem with some python metaprogramming. I want to
> have a decorator which I can use either with functions or methods of
> classes, which will allow me to swap one function or method for another.
> It works as I w
Yeah, it definitely seems like having two separate decorators is the
solution. But the strange thing is that I found this snippet after some
deep googling, that seems to do something *like* what I want, though I
don't understand the descriptor stuff nearly well enough to get what's
happening:
David Hirschfield wrote:
I'm having a little problem with some python metaprogramming. I want to
have a decorator which I can use either with functions or methods of
classes, which will allow me to swap one function or method for another.
It works as I want it to, except that I want to be able
I'm having a little problem with some python metaprogramming. I want to
have a decorator which I can use either with functions or methods of
classes, which will allow me to swap one function or method for another.
It works as I want it to, except that I want to be able to do some
things a littl