[SciPy-Dev] F strings in codebase?

Warren Weckesser warren.weckesser at gmail.com
Fri Jul 3 15:40:26 EDT 2020


On 7/3/20, rlucas7 at vt.edu <rlucas7 at vt.edu> wrote:
> Hi SciPy-dev,
>
> On reviewing this pr:
>
> https://github.com/scipy/scipy/pull/12376
>
> cool-RR was asking about whether f strings are ok in scipy now. I wasn’t
> sure and couldn’t find any, nor clear documentation on a preferred format.


Yes, f-strings are acceptable now.

But I don't think we want to go back and convert all uses of .format()
and '%' to f-strings.  The benefit is probably not worth the code
churn.  So for now, it is probably best to use f-strings in new code,
and when updating old code for some other reason.  E.g. if some
additional information is added to the message of exception, and the
old code uses '%', it would be fine to change it to use an f-string.

Other devs may have different opinions about that, so let's see what
others say before that is considered official policy.

Warren


>
> I know different (parts) of different sub packages may use ‘%’ for
> interpolation and others use .format()
>
> I poked around trying to find examples in codebase but GitHub searching for
> f” didn’t give anything, nor did I find anything in the hacking file or
> related links.
>
> Do we have a preferred string interpolation method for SciPy?
>
> Note the discussion of the string interpolation is about a potential follow
> up PR that cool-RR may do and not the Linked PR itself.
>
> Sincerely,
>
> -Lucas Roberts


More information about the SciPy-Dev mailing list