Get warning for python string literals not having 'u' prefix

To follow the best practices for Unicode in python , you must prefix all string literals of characters with 'u'. Is there any tool (preferably PyDev compatible) that warns if you forget it?

+3
source share
3 answers

you must prefix all string literals with 'u'

No, not at all.

u. - . , , , .

. Unicode PNG ? . base64- Y2Fm6Q==? Unicode , base64 .

, Python , , ASCII. , ASCII, UnicodeError , , unicode. " , " - . .

Python 3, u'', b''. , , '' unicode Python 3. , Python 2 , Python 3 Unicode, . , , Python 3 unicode .

( , b'' Python 2.6 , .)

+4

, - , Python parser dis. pylint.

+2

A KennyTM comment should be posted as an answer:

from __future__ import unicode_literals

This future declaration can be used in Python 2.6 and 2.7 and includes Python 3 string syntax, so unsigned string literals are Unicode strings, and byte arrays require a prefix b.

+1
source

Source: https://habr.com/ru/post/1763949/


All Articles