Why there is no "setdefaultencoding" in sys module?

C

crow

Hi, everyone

I'm a new hand at python.

I tried to set system default encoding by using

"import sys; sys.setdefaultencoding('utf-f')",

but I got error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'setdefaultencoding'

Then I checked dir(sys), seems there was no function named
"setdefaultencoding" in "sys" module. But in python's document, it
said I should use sys.setdefaultencoding.

So, my questions: why there is no setdefaultencoding in sys module? if
I want to change system's default encoding, what should I do?

Thanks in advance
 
C

crow

Interesting, so it has been removed from python? then why it's still
in document... It's really misleading.

Thanks for your quick answer

oh, I take back my words, it's still there, just I need to
reload(sys).
 
T

Thomas Jollans

Interesting, so it has been removed from python? then why it's still
in document... It's really misleading.

Actually, it's still there. Lurking in the corners of sys. But site.py
knows it's evil:

% python
Python 2.6.5+ (release26-maint, Jul 6 2010, 12:58:20)
[GCC 4.4.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.Traceback (most recent call last):
 

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,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top