On Monday, June 25, 2012 11:57:39 PM UTC-7, Peter Otten wrote:
> >
> > There is nothing in the documentation (that I have found) that points to
> > this solution.
>
> That's because I "invented" it.
>
Oh bother. The lines I completely overlooked were in your __getattr__ override.
Boy is my fa
Peter Otten wrote:
>>>helpfunc = getattr(self, "do_" + name[5:]).help
>
> i. e. it looks for getattr(self, "do_help") which does exist and then
Sorry that should be getattr(self, "do_done").
--
http://mail.python.org/mailman/listinfo/python-list
Josh English wrote:
> On Sunday, June 24, 2012 1:07:45 AM UTC-7, Peter Otten wrote:
>>
>> You cannot access a class instance because even the class itself doesn't
>> exist yet. You could get hold of the class namespace with
>> sys._getframe(),
>>
>> def add_help(f):
>> exec """\
>> def help_
On Sunday, June 24, 2012 1:07:45 AM UTC-7, Peter Otten wrote:
>
> You cannot access a class instance because even the class itself doesn't
> exist yet. You could get hold of the class namespace with sys._getframe(),
>
> def add_help(f):
> exec """\
> def help_%s(self):
> f = getattr(self
On 24.06.2012, at 03:58, Josh English wrote:
> I'm creating a cmd.Cmd class, and I have developed a helper method to easily
> handle help_xxx methods.
When I need custom help processing I tend to simply override do_help().
Stefan
http://pypi.python.org/pypi/kmd
--
Stefan H. Holek
ste...@ep
Josh English wrote:
> I'm creating a cmd.Cmd class, and I have developed a helper method to
> easily handle help_xxx methods.
>
> I'm trying to figure out if there is an even lazier way I could do this
> with decorators.
>
> Here is the code:
> *
> import cmd
>
>
> def add_
I'm creating a cmd.Cmd class, and I have developed a helper method to easily
handle help_xxx methods.
I'm trying to figure out if there is an even lazier way I could do this with
decorators.
Here is the code:
*
import cmd
def add_help(func):
if not hasattr(func, 'im_cl