Message319819
Sorry for not describing this one particularly well.
There is nothing wrong with setattr() here, that wasn't the point.
Given the code below (py3, lambdas used for brevity):
# coding: utf-8
from cmd import Cmd
class MyCmd(Cmd):
def do_documented_at_definition(self):
""" This one is documented with docstring. """
pass
def do_documented_afterwards(self):
_ = 'This one will be documented afterwards, with help_<...>() method.'
cli = MyCmd()
cli.do_new_command = lambda *_: print("I'm new here")
cli.help_documented_afterwards = lambda *_: print("I'm documenting")
cli.cmdloop()
1. When one types in "help":
1.1 there is no mention of "new_command" in the output, even though the command works.
1.2 "documented_afterwards" command is being presented as having no documentation at all, but after typing "help documented_afterwards", it turns out that it is not the case.
2. There is no completion for "new_command", i.e. typing in "new_" and pressing tab key will not make it complete to "new_command".
I don't remember what was the use-case for this at the time (probably had something to do with disabling / enabling certain commands at runtime), but the implementation seemed trivial enough that we couldn't see justification for not doing it this way, hence the report. |
|
Date |
User |
Action |
Args |
2018-06-17 15:55:48 | Błażej Michalik | set | recipients:
+ Błażej Michalik, rhettinger, tuxtimo |
2018-06-17 15:55:48 | Błażej Michalik | set | messageid: <1529250948.03.0.56676864532.issue28657@psf.upfronthosting.co.za> |
2018-06-17 15:55:48 | Błażej Michalik | link | issue28657 messages |
2018-06-17 15:55:47 | Błażej Michalik | create | |
|