hi,
one of the modules in my programs stopped wroking after i upgraded from
python 2.3 to 2.4. I also changed my wxPython to unicode supported one
during the process.
what the module essentially does is search for a stirng pattern form a
list of strings.
this is the function:
def srchqu(self):
for i in range(1,len(qu) ):#qu is the list of strings
if qu[i][0].lower().find(s elf.query)==-1:
pass
else:
#do some stuff here
I get this error message on calling the function:
Traceback (most recent call last):
File "E:\mdi\search. py", line 86, in OnSrchButton
self.srchqu()
File "E:\mdi\search. py", line 97, in srchqu
if qu[i][0].lower().find(s elf.query)==-1:
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0x92 in position
66: ordinal not in range(128)
what is the problem and the solution? thanks in advance for any help.
Ashoka 5 5618
"ash" wrote: one of the modules in my programs stopped wroking after i upgraded from python 2.3 to 2.4. I also changed my wxPython to unicode supported one during the process. what the module essentially does is search for a stirng pattern form a list of strings. this is the function:
def srchqu(self): for i in range(1,len(qu) ):#qu is the list of strings if qu[i][0].lower().find(s elf.query)==-1: pass else: #do some stuff here
I get this error message on calling the function:
Traceback (most recent call last): File "E:\mdi\search. py", line 86, in OnSrchButton self.srchqu() File "E:\mdi\search. py", line 97, in srchqu if qu[i][0].lower().find(s elf.query)==-1: UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0x92 in position 66: ordinal not in range(128)
what is the problem and the solution? thanks in advance for any help.
one of qu[i][0] or self.query is a unicode string, and the other is an 8-bit
string that contains something that's not ASCII.
to make the code do what you do, make sure to decode the 8-bit strings
into Unicode strings.
</F>
Thanks Fredrik, i decoded both qu[i][0] and self.query to latin_1
(self.query.dec ode("latin_1")) and i am not getting the error now.
If you dont mind, I have another question for you. I use wxPython for
GUI development. When i use a string containing "&" character as a
label for statictext, the "&" does'nt appear.It is replaced by a short
_. I have tried different encodings but have no success. what should i
do so that "&" appears on screen?
thanks once againg for your help.
regards,
Ashoka
"ash" wrote: If you dont mind, I have another question for you. I use wxPython for GUI development. When i use a string containing "&" character as a label for statictext, the "&" does'nt appear.It is replaced by a short _. I have tried different encodings but have no success. what should i do so that "&" appears on screen?
I don't use wxPython, but & is commonly used by GUI toolkits to place
an underscore under a menu choice, to indicate what hotkey to use
for that menu choice. e.g. "&Save" or "E&xit".
I don't know how to escape that in wxPython. it might be a good idea
to post your question on some wxpython mailing list: http://www.wxpython.org/maillist.php
</F>
ash napisa³(a): If you dont mind, I have another question for you. I use wxPython for GUI development. When i use a string containing "&" character as a label for statictext, the "&" does'nt appear.It is replaced by a short _. I have tried different encodings but have no success. what should i do so that "&" appears on screen?
Double your ampersand character.
--
Jarek Zgoda http://jpa.berlios.de/
Thanks Jarek, doubling worked. I thought it was a problem with encoding
but didnt think of escaping it. thanks a lot.
Thanks for Fredrik too for taking the trouble.
Regards,
Ashoka This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ruslan |
last post by:
Hi, everybody.
In this excerpt of code
enc = 'some_type_of_encoding'
def _encode(v):
if isinstance(v, UnicodeType):
v = v.encode(v)
return v
|
by: Robin Siebler |
last post by:
I have no idea what is causing this error, or how to fix it. The full error is:
Traceback (most recent call last):
File "D:\ScriptRuntime\PS\Automation\Handlers\SCMTestToolResourceToolsBAT.py",
line 60, in Run
PS.Automation.Utility.System.AppendSystemPath(args, context)
File "D:\ScriptRuntime\PS\Automation\Utility\System.py", line 55, in AppendSys
temPath
AppendPathVariable("PATH", appendtext, context)
File...
|
by: dbri.tcc |
last post by:
Hello
I am getting somewhat random UnicodeDecodeError messages in my program.
It is random in that I will be going through a pysqlite database of
records, manipulate
the results, and it will throw UnicodeDecodeError apparently without
regard
as to what data is being used.
|
by: Robin Haswell |
last post by:
Okay I'm getting really frustrated with Python's Unicode handling, I'm
trying everything I can think of an I can't escape Unicode(En|De)codeError
no matter what I try.
Could someone explain to me what I'm doing wrong here, so I can hope to
throw light on the myriad of similar problems I'm having? Thanks :-)
Python 2.4.1 (#2, May 6 2005, 11:22:24)
on linux2
Type "help", "copyright", "credits" or "license" for more information.
|
by: Karl |
last post by:
error msg:
Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)
File "/usr/lib/python2.3/site-packages/mod_python/publisher.py",
| |
by: Oleg Parashchenko |
last post by:
Hello,
I'm working on an unicode-aware application. I like to use "print" to
debug programs, but in this case it was nightmare. The most popular
result of "print" was:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xXX in position
0: ordinal not in range(128)
I spent two hours fixing it, and I hope it's done. The solution is one
|
by: Jorgen Bodde |
last post by:
Hi All,
I am relatively new to python unicode pains and I would like to have
some advice. I have this snippet of code:
def playFile(cmd, args):
argstr = list()
for arg in appcfg.options.split():
thefile = args
filemask = u"%file%"
|
by: Jorgen Bodde |
last post by:
Hi Edwin,
Filemask is obvious as it is assigned in the python code itself. It is
"%file%". The idea is that the file clicked is substituted for the
"%file%" by the replace action. The file that needs to be substituted
is a simple file on disk.
Here is a dump of the file and it's characters. I do understand that
it is not in the range of ASCII but how can I make it so that it will
work?
|
by: Gilles Ganault |
last post by:
Hello
I'm getting this error while downloading and parsing web pages:
=====
title = m.group(1)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position
48: ordinal not in range(128)
=====
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |