Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-10 Thread Kannan Varadhan
Thanks folks, Tried all of these, and went with staticmethod(). Was cleanest solution, > After skimming over Steven's post: use staticmethod. > No idea why I didn't think of that myself. Kannan -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Peter Otten
Peter Otten wrote: > or you wrap the callable in a descriptor: > def DefaultTracer(*args): print args > ... class D(object): > ... def __init__(self, f): > ... self.f = f > ... def __get__(self, *args): > ... return self.f > ... After skimming over Steve

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Paul Rudin
Steven D'Aprano writes: > Please don't post code with line numbers. That makes it difficult to copy > and paste your function into an interactive session, so that we can run it > and see what it does. C-x r d -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Steven D'Aprano
lass().trace('Using ClassDefaultTracer') > File "foo.py", line 14, in trace > self.InstanceTracer(fmt, *args) > TypeError: unbound method DefaultTracer() must be called with MyClass > instance as first argument (got str instance instead) Unfortunately you'

Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Peter Otten
$ python foo.py > in DefaultTracer Testing at first > in myTracer Testing at first > Traceback (most recent call last): > File "foo.py", line 20, in > MyClass().trace('Using ClassDefaultTracer') > File "foo.py", line 14, in trace > self.InstanceTr

TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Kannan Varadhan
lassDefaultTracer') File "foo.py", line 14, in trace self.InstanceTracer(fmt, *args) TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead) Alternately, how can I achieve what I want, i.e. a class-wide default