[Python-Dev] Re: Minor inconvenience: f-string not recognized as docstring

2022年1月11日 08:11:33 -0800

On 2022年1月11日 10:58:03 -0500
"Eric V. Smith" <[email protected]> wrote:
> Constant f-strings (those without substitutions) as doc strings used to 
> work, since the compiler turns them into normal strings.
> 
> I can't find exactly where it was removed, but there was definitely 
> discussion about it. See https://bugs.python.org/issue28739 for at least 
> part of the discussion.
Ah, sorry for the misunderstanding. While the example I showed doesn't
have any substitutions, I'm interested in the non-trivial (non-constant)
case actually :-)
Regards
Antoine.
> 
> Eric
> 
> On 1/11/2022 8:41 AM, Antoine Pitrou wrote:
> > Hello,
> >
> > Currently, a f-string is not recognized as a docstring:
> > 
> >>>> class C: f"foo"
> >>>> C.__doc__
> >>>> 
> > This means you need to use a (admittedly easy) workaround:
> > 
> >>>> class C: __doc__ = f"foo"
> >>>> C.__doc__ 
> > 'foo'
> >
> > Shouldn't the former be allowed for convenience?
> >
> > Regards
> >
> > Antoine.
> >
> >
> > _______________________________________________
> > Python-Dev mailing list -- [email protected]
> > To unsubscribe send an email to [email protected]
> > https://mail.python.org/mailman3/lists/python-dev.python.org/
> > Message archived at 
> > https://mail.python.org/archives/list/[email protected]/message/UALMEMQ4QW7W4HE2PIBARWYBKFWJZFB4/
> > Code of Conduct: http://python.org/psf/codeofconduct/ 
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/37YAHCREZYZFSV4BRDKUEQAX4ZF4JTI6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to