This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Błażej Michalik
Recipients Błażej Michalik, rhettinger, tuxtimo
Date 2018-06-17.15:55:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529250948.03.0.56676864532.issue28657@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-06-17 15:55:48Błażej Michaliksetrecipients: + Błażej Michalik, rhettinger, tuxtimo
2018-06-17 15:55:48Błażej Michaliksetmessageid: <1529250948.03.0.56676864532.issue28657@psf.upfronthosting.co.za>
2018-06-17 15:55:48Błażej Michaliklinkissue28657 messages
2018-06-17 15:55:47Błażej Michalikcreate