Enable Unicode "globally" in Python -
Is it possible to avoid placing it in every page?
Thank you in advance!
In Python 3, the default encoding is UTF-8, so you will not set it explicitly now There is no way to set 'default source encoding' globally, though, and history has shown that such global options are generally a bad idea. (For example, -U and -Q options, Python, and sys.setdefaultencoding () back when we did it.) You do not control (directly) all sources imported into your program, because it includes standard library and any There are also third-party modules that you use directly or indirectly.
Also keep in mind that this is not enabling Unicode according to the title of your question. What it does is source encoding UTF-8, which means that any non-ASCII characters (like u'spæm '
) in Unicode literals will be interpreted using that encoding. This non-Unicode literal ( 'spam'
and "spam"
) will not suddenly create Unicode, nor will it do anything for non-written words anywhere in your code .
Comments
Post a Comment