473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

sys.setdefaultencoding(name)

Where is the method : "sys.setdefaultencoding(name)"?

Problem :
I want change the default encoding because I want put french letter :
éÉàÀ...etc in widget with no problem! When I use the method ".get" from a
widget (Text, Entry), the string returned is "fucked"...
In the Entry widget, the text is (with .insert) "été"
When I add a "é" at end (with my keyboard), th result is "étéé" OR a
raised error!

I find, on net, that I must use "sys.setdefaultencoding(name)".
I find find this methode in the doc (official) but the
"setdefaultencoding" name method is not in the sys module!?! (when I print
"dir(sys)"?! :-(

Askari
Jul 18 '05 #1
5 2906
Askari,
When I use the method ".get" from a widget (Text, Entry), the string
returned is "fucked"...
That must be a virus or something. Encoding issues normally provide garbled
strings, but not the word "fucked". Somebody is playing jokes with you.
I find, on net, that I must use "sys.setdefaultencoding(name)".


setdefaultencoding gets removed from sys after execution of site.py /
sitecustomize.py.

My solution is to grab site.py, dig up "default encoding" and change from
imperalistic ASCII to LATIN-1.

Some told me that avangarde persons also take UTF8.

Harald

Jul 18 '05 #2
Harald Massa wrote:
Askari,
When I use the method ".get" from a widget (Text, Entry), the string
returned is "fucked"...


That must be a virus or something. Encoding issues normally provide garbled
strings, but not the word "fucked". Somebody is playing jokes with you.


I doubt that the quotes in the OP indicate a literal string.

Reinhold

--
[Windows ist wie] die Bahn: Man muss sich um nichts kuemmern, zahlt fuer
jede Kleinigkeit einen Aufpreis, der Service ist mies, Fremde koennen
jederzeit einsteigen, es ist unflexibel und zu allen anderen Verkehrs-
mitteln inkompatibel. -- Florian Diesch in dcoulm
Jul 18 '05 #3
Harald Massa <cp*********@spamgourmet.com> wrote in
news:Xn**********************************@195.20.2 24.116:
My solution is to grab site.py, dig up "default encoding" and change
from imperalistic ASCII to LATIN-1.


euh... I try (the line #2 and #3 in my ".py"):
"""
import site
site.encoding = "latin_1"
"""

but I have this error when I modify a widget (with keyboard) I have this
error :
"""
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc9 in position 0:
ordinal not in range(128)
"""

Why?
And, I do the good think? (site.encoding = "latin_1")
Askari
Jul 18 '05 #4
Askari,
"""
import site
site.encoding = "latin_1"
"""

Why?
And, I do the good think? (site.encoding = "latin_1")


No, you do a the bad thing.

You have to EDIT the site.py within python\lib\site.py

open it within an editor, find "ASCII" and replace by latin1

site.encodiging="Latin_1" just adds an attribute NOBODY cares for to a
module in memory.

Harald
Jul 18 '05 #5
Harald Massa <cp*********@spamgourmet.com> wrote in
news:Xn**********************************@195.20.2 24.116:
Askari,
"""
import site
site.encoding = "latin_1"
"""

Why?
And, I do the good think? (site.encoding = "latin_1")


No, you do a the bad thing.

You have to EDIT the site.py within python\lib\site.py

open it within an editor, find "ASCII" and replace by latin1

site.encodiging="Latin_1" just adds an attribute NOBODY cares for to a
module in memory.

Harald


It work! :-)

Thanks!

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Laurent Therond | last post by:
Maybe you have a minute to clarify the following matter... Consider: --- from cStringIO import StringIO def bencode_rec(x, b): t = type(x)
4
by: Alex | last post by:
Rossum's tutorial states "Actually, modules are searched in the list of directories given by the variable sys.path which is initialized from the directory containing the input script (or the...
6
by: ygao | last post by:
>>> import sys >>> sys.setdefaultencoding("utf-8") >>> s='\xe9\xab\x98' #this uff-8 string >>> ss=U'\xe9\xab\x98' >>> s '\xe9\xab\x98' >>> ss u'\xe9\xab\x98' >>> how do I get ss from s?
6
by: Raphael.Benedet | last post by:
Hello, For my application, I would like to execute an SQL query like this: self.dbCursor.execute("INSERT INTO track (name, nbr, idartist, idalbum, path) VALUES ('%s', %s, %s, %s, '%s')" %...
2
by: Ben Edwards (lists) | last post by:
I am using python 2.4 on Ubuntu dapper, I am working through Dive into Python. There are a couple of inconsictencies. Firstly sys.setdefaultencoding('iso−8859−1') does not work,I have to...
2
by: enquiring mind | last post by:
I read the posting by Rehceb Rotkiv and response but don't know if it relates to my problem in any way. I only want to write German to the screen/console for little German programs/exercises in...
7
bigturtle
by: bigturtle | last post by:
Using Python 2.6, I am trying to pickle a dictionary (for Chinese pinyin) which contains both Unicode characters in the range 128-255 and 4-byte Unicode characters. I get allergic reactions from...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.