I am writing a .py file that contains strings from multiple charactersets, including English, Spanish, and Russian. For example, I have something like:
string_en
There are two aspects to proper encoding of strings in your use case:
For Python to understand that you are using UTF-8 encoding, you must include in the first or second line of your code, a line that looks like # coding=utf-8
. See PEP 0263 for details.
Your editor also must use UTF-8. This requires to configure it, and depends on the editor you are using. Configuration of Emacs and Vim are addressed in the same PEP, Eclipse can default to the filesystem encoding, which itself can be derived from your locale settings, etc.