Setting stdout encoding

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Sep 13 02:09:09 EDT 2007


En Tue, 11 Sep 2007 07:58:03 -0300, Fabio Zadrozny <fabiofz at gmail.com>  
escribi�:

>> You could place code like that on sitecustomize.py
>> I think this should be fixed on Eclipse/pydev. If they replace  
>> sys.stdout
>> with a different object - they should make sure it has the right  
>> behavior.
>> Same for IDLE if it's broken too.
>>
>
> Thanks for the tip... I wasn't aware of sitecustomize.py (site.py does  
> call
> that just before removing setdefaultencoding() from sys, so I can still  
> use
> sys.setdefaultencoding)... actually, setencoding() from site.py does have
> what I would like to execute:
>     if 0:
>         # Enable to support locale aware default string encodings.
>         import locale
>         loc = locale.getdefaultlocale()
>         if loc[1]:
>             encoding = loc[1]
>
> I just don't get why the code has that "if 0:" instead of getting it from
> some user-config (like env variable or parameters passed)...
>
> Anyways, thanks a lot... I think I can arrange in providing a
> sitecustomize.py from pydev with that structure.

But I don't think it's a good idea. Changing the default encoding will  
change it for *all* scripts, *all* users, *all* objects. And AFAIK you  
have trouble ONLY with sys.std* - one should fix those objects, not mess  
with a global configuration.

-- 
Gabriel Genellina




More information about the Python-list mailing list