Why there is no "setdefaultencoding" in sys module?

Discussion in 'Python' started by crow, Jul 9, 2010.

  1. crow

    crow Guest

    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
    crow, Jul 9, 2010
    1. Advertisements

  2. Steven D'Aprano, Jul 9, 2010
    1. Advertisements

  3. crow

    crow Guest

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

    Thanks for your quick answer
    crow, Jul 9, 2010
  4. crow

    crow Guest

    oh, I take back my words, it's still there, just I need to
    crow, Jul 9, 2010
  5. 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):
    Thomas Jollans, Jul 9, 2010
  6. crow

    Terry Reedy Guest

    Where? That may need to be changed.
    Terry Reedy, Jul 9, 2010
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.