[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Daniel Walker
Thank you On Sat, Jun 26, 2021 at 8:10 PM Guido van Rossum wrote: > Okay, then Chris Barker’s explanation applies. > > On Sat, Jun 26, 2021 at 16:35 Daniel Walker wrote: > >> I wasn't looking at the type stub but cmd.py itself. It has >> >> PROMPT = '(Cmd) ' >> ... >> >> class Cmd: >>

[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Guido van Rossum
Okay, then Chris Barker’s explanation applies. On Sat, Jun 26, 2021 at 16:35 Daniel Walker wrote: > I wasn't looking at the type stub but cmd.py itself. It has > > PROMPT = '(Cmd) ' > ... > > class Cmd: > prompt = PROMPT > ... > > On Sat, Jun 26, 2021 at 6:04 PM Guido van Rossum

[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Daniel Walker
Found the mypy bug: https://github.com/python/mypy/issues/4125 On Sat, Jun 26, 2021 at 7:35 PM Daniel Walker wrote: > I wasn't looking at the type stub but cmd.py itself. It has > > PROMPT = '(Cmd) ' > ... > > class Cmd: > prompt = PROMPT > ... > > On Sat, Jun 26, 2021 at 6:04 PM

[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Daniel Walker
I wasn't looking at the type stub but cmd.py itself. It has PROMPT = '(Cmd) ' ... class Cmd: prompt = PROMPT ... On Sat, Jun 26, 2021 at 6:04 PM Guido van Rossum wrote: > On Sat, Jun 26, 2021 at 9:25 AM Daniel Walker wrote: > >> I was recently using the cmd module for a project

[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Guido van Rossum
On Sat, Jun 26, 2021 at 9:25 AM Daniel Walker wrote: > I was recently using the cmd module for a project where my CLI > could connect to and interact with another host. I implemented prompt in > such a way that it would show the IP address when connected. I.e., > > class MyCmd(cmd.Cmd): >

[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Christopher Barker
A class attribute provides a default that’s the same for all instances, but does let you customize it with a simple attribute assignment. Which seems like the right thing in this case. class Cmd: > PROMPT = '> ' > > @property > def prompt(self) -> str: >

[Python-Dev] Re: cmd.Cmd.prompt should be an instance attribute

2021-06-26 Thread Daniel Walker
Sorry, that implementation should have been class Cmd: PROMPT = '> ' @property def prompt(self) -> str: return self.PROMPT ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to