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

2020-09-19 Thread Tal Einat
Tal Einat added the comment: I agree with Raymond's reasoning on this. Following the discussion, I'm closing this as wontfix. Thanks to everyone involved for the detailed, clear and focused discussion. -- nosy: +taleinat resolution: -> wont fix stage: patch review -> resolved

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

2019-01-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: > Maybe the methods could all rely on `get_names` that > return `dir(self.__class__)`, Please read the previous posts on the subject. The only reason to do this is if we want the module to explicitly support attaching methods directly to instances.

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

2019-01-14 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: CC-ing Catherine Devlin and Todd Leonhardt so we can close the issue by either accepting or refusing such feature. -- ___ Python tracker ___

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

2019-01-14 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- nosy: +catherinedevlin, tleonhardt ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2018-07-10 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi Raymond, would updating the attached PR to change https://github.com/remilapeyre/cpython/blob/7c78350f8903f162e5f70ee147c0e97cb1ed5181/Lib/cmd.py#L270 (and others) from `compfunc = getattr(self, 'complete_' + cmd)` to `compfunc = getattr(self.__class__,

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

2018-07-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: >> Could this have been done with: >> setattr(self.__class__, "do_" + command, func)? > Isn't that worse than doing that on an instance? It will work > as long as there's only one. Why not have multiple classes instead of multiple instances? Then use

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

2018-07-09 Thread Błażej Michalik
Błażej Michalik added the comment: It seems to me as if the current implementation forces the user to violate SRP, but I'm not going to argue about that. I don't feel equipped well enough to judge. > Could this have been done with: setattr(self.__class__, "do_" + command, > func)? Isn't

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

2018-07-05 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: later -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2018-07-05 Thread Raymond Hettinger
Raymond Hettinger 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

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

2018-07-03 Thread Błażej Michalik
Błażej Michalik added the comment: I found it. Our app had CLI that was so vast, that it didn't made sense to put all of the 'do_xyz' methods into the same class that would run the interface internals. Instead, we had a child Cmd class that had a "add_command(self, command, func,

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

2018-07-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: Okay, I'll mark this as on-hold until you find the relevant code. I'm not sure why you think modifying the class definition would look weird. That is the normal and intended place to put methods. Likely, the only reason that you had any success at all

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

2018-06-30 Thread Błażej Michalik
Błażej Michalik added the comment: It was nearly 2 years ago when we needed it, and we avoided the issue by overriding get_names(). I'll have to find the code in which this was used to answer your question. I guess we could've modified the class definition, however weirdly would that look.

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

2018-06-30 Thread Raymond Hettinger
Raymond Hettinger added the comment: Błażej, why is there a need to attach a function to the cli instance rather than the MyCmd class (which would be the norm for Python)? from cmd import Cmd class MyCmd(Cmd): def do_documented_at_definition(self, arg): """ This

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

2018-06-30 Thread Błażej Michalik
Błażej Michalik added the comment: Yes, the proposed patch fixes all the problems that I pointed out in the last comment. -- ___ Python tracker ___

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

2018-06-29 Thread Rémi Lapeyre
Rémi Lapeyre added the comment: Hi Błażej Michalik, can you confirm the attached patch fixed the issue for you? -- nosy: +remi.lapeyre ___ Python tracker ___

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

2018-06-29 Thread Rémi Lapeyre
Change by Rémi Lapeyre : -- keywords: +patch pull_requests: +7623 stage: -> patch review ___ Python tracker ___ ___

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

2018-06-17 Thread Błażej Michalik
Błażej Michalik added the comment: 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

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

2018-05-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: ISTM the only way dir(self) would make a difference would be if functions we being assigned to instances rather than the class. Also, it's uncleaar why setattr() is at issue -- it works the same way as regular attribute assignment using the dot

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

2018-05-31 Thread Timo Furrer
Change by Timo Furrer : -- nosy: +tuxtimo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

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

2016-11-10 Thread Błażej Michalik
New submission from Błażej Michalik: The issue here seems to originate from the implementation of Cmd.get_names(): def get_names(self): # This method used to pull in base class attributes # at a time dir() didn't do it yet.