Re: [Tutor] What is the trick ???!

2011-05-12 Thread Karim

On 05/12/11 21:24, Karim wrote:


Hello

See below, I was surprised about finding hidden function in module sys:

karim@Requiem4Dream: python2.7
Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>> sys.setdefaultencoding()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>>
karim@Requiem4Dream:~/build/OpenProcessManager/test$ python2.7
Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>> sys.setdefaultencoding('utf-8')
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>> reload(sys)

>>> sys.setdefaultencoding('utf-8')
>>> sys.getdefaultencoding()
'utf-8'
>>>

:-\ ???
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Ok I found the trick at 
http://docs.python.org/library/sys.html#sys.setdefaultencoding.
The function is removed dynamically at startup when reload I get the 
nominal one

(the original).

Sorry for the disturb.
Cheers
Karim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What is the trick ???!

2011-05-12 Thread Karim


Hello

See below, I was surprised about finding hidden function in module sys:

karim@Requiem4Dream: python2.7
Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>> sys.setdefaultencoding()
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>>
karim@Requiem4Dream:~/build/OpenProcessManager/test$ python2.7
Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getdefaultencoding()
'ascii'
>>> sys.setdefaultencoding('utf-8')
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'setdefaultencoding'
>>> reload(sys)

>>> sys.setdefaultencoding('utf-8')
>>> sys.getdefaultencoding()
'utf-8'
>>>

:-\ ???
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor