[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

Raymond Hettinger report at bugs.python.org
Thu Jul 5 19:34:05 EDT 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

> That method would then perform an assignment with setattr() calls: setattr(self, "do_" + command, func).

Could this have been done with:  setattr(self.__class__, "do_" + command, func)?

I'm concerned that attaching functions to the instance is fighting the Python norms and the design of the module.  It seems like a can of worms.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue28657>
_______________________________________


More information about the Python-bugs-list mailing list