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:
>
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
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
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
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
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:
>>
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):
...
@property
def prompt(self) -> str:
if
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):
>