So my script is in the folder which contains cyrillic symbols in the path and the __file__
variabale returns "encoding error" instead of a real path.
Adding the following line doesnt help
# -*- coding: cp1252 -*-
What should I do?
Version of python 3.3
I'm not sure if this answers your question, but...
In python3 the
__file__
holds the current running script and path as astr
. *nix systems use binary for filenames and have no preference for a particular encoding. When you use__file__
the system will attempt to take the binary string and encode it into a string using the default encoding system. I'm wondering if maybe your filenames are in cp1252 and python is trying to interpret it as utf8.Python may follow the convention outlined here when encoding
__file__
: http://docs.python.org/2/library/sys.html#sys.getfilesystemencodingYou didn't state what OS you're using, though...