Re: Why there is no "setdefaultencoding" in sys module?
On Friday, July 9, 2010 at 9:28:35 PM UTC+5:30, crow wrote: > 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: > > >>> sys.setdefaultencoding('utf-8') > Traceback (most recent call last): > File "", line 1, in > 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 Becuase you are using python 3.setdefaultencoding is no longer supportedin python 3. python3automatically have utf-8 in its configuration by default. so you don't have to use it. just remove the line. -- https://mail.python.org/mailman/listinfo/python-list
Why there is no setdefaultencoding in sys module?
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: sys.setdefaultencoding('utf-8') 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: Why there is no setdefaultencoding in sys module?
On Fri, 09 Jul 2010 08:58:35 -0700, crow wrote: So, my questions: why there is no setdefaultencoding in sys module? if I want to change system's default encoding, what should I do? I think the answer is: Don't. If you do, you will break built-ins. http://tarekziade.wordpress.com/2008/01/08/syssetdefaultencoding-is-evil/ Googling will find many discussions about this. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Why there is no setdefaultencoding in sys module?
On Jul 10, 12:04 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Fri, 09 Jul 2010 08:58:35 -0700, crow wrote: So, my questions: why there is no setdefaultencoding in sys module? if I want to change system's default encoding, what should I do? I think the answer is: Don't. If you do, you will break built-ins. http://tarekziade.wordpress.com/2008/01/08/syssetdefaultencoding-is-e... Googling will find many discussions about this. -- Steven Interesting, so it has been removed from python? then why it's still in document... It's really misleading. Thanks for your quick answer -- http://mail.python.org/mailman/listinfo/python-list
Re: Why there is no setdefaultencoding in sys module?
On Jul 10, 12:06 am, crow wen...@gmail.com wrote: On Jul 10, 12:04 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Fri, 09 Jul 2010 08:58:35 -0700, crow wrote: So, my questions: why there is no setdefaultencoding in sys module? if I want to change system's default encoding, what should I do? I think the answer is: Don't. If you do, you will break built-ins. http://tarekziade.wordpress.com/2008/01/08/syssetdefaultencoding-is-e... Googling will find many discussions about this. -- Steven 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). -- http://mail.python.org/mailman/listinfo/python-list
Re: Why there is no setdefaultencoding in sys module?
On 07/09/2010 06:06 PM, crow wrote: On Jul 10, 12:04 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Fri, 09 Jul 2010 08:58:35 -0700, crow wrote: So, my questions: why there is no setdefaultencoding in sys module? if I want to change system's default encoding, what should I do? I think the answer is: Don't. If you do, you will break built-ins. http://tarekziade.wordpress.com/2008/01/08/syssetdefaultencoding-is-e... Googling will find many discussions about this. -- Steven 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. import sys sys.setdefaultencoding Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'module' object has no attribute 'setdefaultencoding' reload(sys) module 'sys' (built-in) sys.setdefaultencoding built-in function setdefaultencoding -- http://mail.python.org/mailman/listinfo/python-list
Re: Why there is no setdefaultencoding in sys module?
oh, I take back my words, it's still there, just I need to reload(sys). Just don't. If you change the default encoding you are going to break important data structures like dicts in a subtle and hard to detect way. If your application needs to change the default encoding, it's broken. The function is removed for a very good reaso. -- http://mail.python.org/mailman/listinfo/python-list
Re: Why there is no setdefaultencoding in sys module?
On 7/9/2010 11:58 AM, crow wrote: But in python's document, it said I should use sys.setdefaultencoding. Where? That may need to be changed. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list