Issue 33551: The string prefixes u and f can't used together

Issue33551

Created on 2018-05-17 06:25 by Aifu LIU, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg316883 - (view) Author: Aifu LIU (Aifu LIU) Date: 2018-05-17 06:25
The string prefixes u and f can't used together, for example:

>>> age = 30
>>> s = uf'年龄:{age}'
  File "<stdin>", line 1
    s = uf'年龄:{age}'
                   ^
SyntaxError: invalid syntax
>>>
msg316884 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-05-17 06:38
Why would you want to do that?
msg316890 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-05-17 07:10
The string prefix u is used exclusively for compatibility with Python 2. It helps writing code that works in Python 2 and Python 3. The string prefix f is not compatible with Python 2. If you use it, you no longer have reasons for using the string prefix u.
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77732
2018-05-17 07:10:00serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg316890

resolution: not a bug
stage: resolved

2018-05-17 06:38:52benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg316884
2018-05-17 06:25:08Aifu LIUcreate