This question exists on this website but it is flawed as it returns a <type 'str'>
(both when using __file__
and when using the module inspect
) and not a <type 'unicode'>
which I need as my path contains non-ascii characters (Hebrew characters, to be specific).
How can I get the path and filename of current running script in <type 'unicode'>
in the file system encoding? Is there any Unicode-friendly function built-in for doing so or any solution?
Just calling __file__.encode(sys.getfilesystemencoding())
fails with ascii codec can't decode byte ...
.