What is the encoding of __file__?

G

Guest

Dear all,

can someone quickly tell me what the encoding of __file__ is? I can't
find it in the documentation.

BTW, I'm using Python 2.5.1 on WIndows XP and Vista.

Kind regards,
Sebastian
 
M

Martin v. Löwis

can someone quickly tell me what the encoding of __file__ is? I can't
find it in the documentation.

BTW, I'm using Python 2.5.1 on WIndows XP and Vista.

It's platform-specific - the same encoding that is used for file names
(i.e. sys.getfilesystemencoding()). On Windows, it will be "mbcs", which
in turn is installation-specific - on Western European/US installations,
it's "windows-1252".

Regards,
Martin
 
G

Guest

It's platform-specific - the same encoding that is used for file names
(i.e. sys.getfilesystemencoding()). On Windows, it will be "mbcs", which
in turn is installation-specific - on Western European/US installations,
it's "windows-1252".

Thanks, I'll then use sys.getfilesystemencoding() to decode _file__
and re-encode into utf-8, which is the default encoding of all strings
in our software, as we deal a bit with Chinese terms.

Windows-1252 on my box. I just created a directory containing Chinese
characters (on Vista), and whoa, files opened with IDLE are empty,
import doesn't find modules in that directory. Of course Windows-1252
can't encode these ...

But I understand that Python 3 will clean this up?

Kind regards,
Sebastian
 
M

Martin v. Löwis

Thanks, I'll then use sys.getfilesystemencoding() to decode _file__
and re-encode into utf-8, which is the default encoding of all strings
in our software, as we deal a bit with Chinese terms.

Windows-1252 on my box. I just created a directory containing Chinese
characters (on Vista), and whoa, files opened with IDLE are empty,
import doesn't find modules in that directory. Of course Windows-1252
can't encode these ...

But I understand that Python 3 will clean this up?

In theory, yes. The current implementation doesn't.

Contributions are welcome.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top