encoding problems (é and è)
hi i'am making a program for formatting string,
or
i've added :
#!/usr/bin/python
# -*- coding: utf-8 -*-
in the begining of my script but
str = str.replace('Ç', 'C')
str = str.replace('é', 'E')
str = str.replace('É', 'E')
str = str.replace('è', 'E')
str = str.replace('È', 'E')
str = str.replace('ê', 'E')
doesn't work it put me " and , instead of remplacing é by E
if someone have an idea it could be great
regards
Bussiere
ps : i've added the whole script under :
__
#!/usr/bin/python
# -*- coding: utf-8 -*-
import fileinput, glob, string, sys, os, re
fichA=raw_input("Entrez le nom du fichier d'entree : ")
print ("\n")
fichC=raw_input("Entrez le nom du fichier de sortie : ")
print ("\n")
normalisation1 = raw_input("Normaliser les adresses 1 (ex : Avenue->
AV) (O/N) ou A pour tout normaliser \n")
normalisation1 = normalisation1.upper()
if normalisation1 != "A":
print ("\n")
normalisation2 = raw_input("Normaliser les civilités (ex :
Docteur-> DR) (O/N) \n")
normalisation2 = normalisation2.upper()
print ("\n")
normalisation3 = raw_input("Normaliser les Adresses 2 (ex :
Place-> PL) (O/N) \n")
normalisation3 = normalisation3.upper()
normalisation4 = raw_input("Normaliser les caracteres / et - (ex :
/ -> ) (O/N) \n" )
normalisation4 = normalisation4.upper()
if normalisation1 == "A":
normalisation1 = "O"
normalisation2 = "O"
normalisation3 = "O"
normalisation4 = "O"
fiA=open(fichA,"r")
fiC=open(fichC,"w")
compteur = 0
while 1:
ligneA=fiA.readline()
if ligneA == "":
break
if ligneA != "":
str = ligneA
str = str.replace('a', 'A')
str = str.replace('b', 'B')
str = str.replace('c', 'C')
str = str.replace('d', 'D')
str = str.replace('e', 'E')
str = str.replace('f', 'F')
str = str.replace('g', 'G')
str = str.replace('h', 'H')
str = str.replace('i', 'I')
str = str.replace('j', 'J')
str = str.replace('k', 'K')
str = str.replace('l', 'L')
str = str.replace('m', 'M')
str = str.replace('n', 'N')
str = str.replace('o', 'O')
str = str.replace('p', 'P')
str = str.replace('q', 'Q')
str = str.replace('r', 'R')
str = str.replace('s', 'S')
str = str.replace('t', 'T')
str = str.replace('u', 'U')
str = str.replace('v', 'V')
str = str.replace('w', 'W')
str = str.replace('x', 'X')
str = str.replace('y', 'Y')
str = str.replace('z', 'Z')
str = str.replace('ç', 'C')
str = str.replace('Ç', 'C')
str = str.replace('é', 'E')
str = str.replace('É', 'E')
str = str.replace('è', 'E')
str = str.replace('È', 'E')
str = str.replace('ê', 'E')
str = str.replace('Ê', 'E')
str = str.replace('ë', 'E')
str = str.replace('Ë', 'E')
str = str.replace('ä', 'A')
str = str.replace('Ä', 'A')
str = str.replace('à', 'A')
str = str.replace('À', 'A')
str = str.replace('Á', 'A')
str = str.replace('Â', 'A')
str = str.replace('Ä', 'A')
str = str.replace('Ã', 'A')
str = str.replace('â', 'A')
str = str.replace('Ä', 'A')
str = str.replace('ï', 'I')
str = str.replace('Ï', 'I')
str = str.replace('î', 'I')
str = str.replace('Î', 'I')
str = str.replace('ô', 'O')
str = str.replace
[Pickle]dirty problem 3 lines
i know it's dirty, i know i should use json but i want to know, it's quiet late here : import pickle dump = """b'\x80\x03]q\x00(K\x00K\x01e.'""" print(pickle.loads(dump)) how can i get back my object from this string ? the string is : b'\x80\x03]q\x00(K\x00K\x01e.' and i'am using python3 help will be appreciated i'am chewing on this for a long time now. Regards B. fan of dresden files -- http://mail.python.org/mailman/listinfo/python-list
Re: [Pickle]dirty problem 3 lines
it's just as it seems :
i want to know how does ti works to get back an object from a string in python :
pickle.loads("""b'\x80\x03]q\x00(K\x00K\x01e.'""") #doesn't work
Google Fan boy
On Wed, Sep 1, 2010 at 5:23 AM, MRAB wrote:
> On 01/09/2010 03:33, bussiere bussiere wrote:
>>
>> i know it's dirty, i know i should use json but i want to know, it's
>> quiet late here :
>> import pickle
>> dump = """b'\x80\x03]q\x00(K\x00K\x01e.'"""
>> print(pickle.loads(dump))
>>
>> how can i get back my object from this string ?
>> the string is : b'\x80\x03]q\x00(K\x00K\x01e.'
>> and i'am using python3
>> help will be appreciated i'am chewing on this for a long time now.
>
> Well, pickle.loads(b'\x80\x03]q\x00(K\x00K\x01e.') works.
>
> That, of course, is not the same as """b'\x80\x03]q\x00(K\x00K\x01e.'""".
>
> Do you mean r"""b'\x80\x03]q\x00(K\x00K\x01e.'"""?
>
> (It's also late here, well, actually, so late it's early... Time to
> sleep. :-))
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: dirty problem 3 lines
It seems to work perfectly
thanks a lot
Bussiere
Google Fan boy
On Thu, Sep 2, 2010 at 7:32 AM, alex23 wrote:
> bussiere bussiere wrote:
>> it's just as it seems :
>> i want to know how does ti works to get back an object from a string in
>> python :
>> pickle.loads("""b'\x80\x03]q\x00(K\x00K\x01e.'""") #doesn't work
>
> Repeating the question without providing any further information
> doesn't really help.
>
> This is a byte string: b'\x80\x03]q\x00(K\x00K\x01e.'
> As MRAB points out, you can unpickle a byte string directly.
>
> This is a doc string: """note the triplet of double quotes"""
> What you have is a doc string that appears to contain a byte string:
> """b'\x80\x03]q\x00(K\x00K\x01e.'"""
>
> So the question for you is: what is putting the byte string inside of
> a doc string? If you can stop that from happening, then you'll have a
> byte string you can directly unpickle.
>
> Now, if you _don't_ have control over whatever is handing you the dump
> string, then you can just use string manipulation to reproduce the
> byte string:
>
>>>> dump = """b'\x80\x03]q\x00(K\x00K\x01e.'"""
>>>> badump = dump[2:-1].encode()[1:]
>>>> pickle.loads(badump)
> [0, 1]
>
> So:
> - dump[2:-1] strips off string representation of the byte string
> (b'...')
> - .encode() turns it into an actual byte string
> - [1:] strips a unicode blank from the start of the byte string (not
> entirely sure how that gets there...)
>
> After that it should be fine to unpickle.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
include a file in a python program
i've got a python.txt that contain python and it must stay as it (python.txt)
how can i include it in my program ?
import python.txt doesn't work
is there a way :
a) to make an include("python.txt")
b) tell him to treat .txt as .py file that i can make an import python ?
i'am using python3
Regards
Bussiere
fan of torchwood
Google Fan boy
--
http://mail.python.org/mailman/listinfo/python-list
knowing the caller of an import && exec question
i've got toto.py :
import titi
def niwhom():
pass
and titi.py :
def nipang():
pass
how can i know in titi.py that's it's toto.py that is calling titi.py
and the path of toto ?
And
why :
bidule.py :
class bidetmusique:
pass
truc.py :
X = __import__("bidule")
why exec("X.bidetmusique()") return none
and X.bidetmusique() return an object ?
How could i do to make this string "X.bidetmusique()" return an object ?
Regards and thanks
Bussiere
Eat the strawberry
Google Fan boy
--
http://mail.python.org/mailman/listinfo/python-list
Re: include a file in a python program
Thanks all for your response i will try out this week, you have give me sufficient hints. Thanks again. Bussiere -- http://mail.python.org/mailman/listinfo/python-list
inspect the call stack
i v'e got this : i've got toto.py : import titi def niwhom(): pass and titi.py : def nipang(): pass how can i know in titi.py that's it's toto.py that is calling titi.py and the path of toto ? how can i inspect the call stack or an other way ? Regards Bussiere Google Fan boy -- http://mail.python.org/mailman/listinfo/python-list
socket problem and html problem
here is my code and two questions :
why it says to me that i can't bind the socket ?
normally it had closed it and kill it :/
and why it returns me plain text and not html ?
Regards and a pack of m&m's to the one who will help me on this two
questions.
import socket
import sys
# Create a TCP/IP socket
class Serverhttp:
def __init__(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_address = ('localhost', 2)
print >>sys.stderr, 'starting up on %s port %s' % server_address
sock.bind(server_address)
# Listen for incoming connections
sock.listen(1)
off = 2
self.message = ""
while True:
# Wait for a connection
print >>sys.stderr, 'waiting for a connection'
if off == 2 or off == 1:
connection, client_address = sock.accept()
try:
print >>sys.stderr, 'connection from', client_address
# Receive the data in small chunks and retransmit it
while True:
if off == 1:
sock = socket.socket(socket.AF_INET,
socket.SOCK_STREAM)
server_address = ('localhost', 17000)
sock.bind(server_address)
connection, client_address = sock.accept()
off = 0
data = connection.recv(1024)
print >>sys.stderr, 'received "%s"' % data
if data:
self.message = self.traitement(data)
connection.sendall(self.message)
connection.close()
sock.close()
del(sock)
off = 1
else:
print >>sys.stderr, 'no more data from',
client_address
break
finally:
# Clean up the connection
connection.close()
def traitement(self,string):
return
"Content-type:text/html;charset=utf8\n\ntest"
if __name__ == "__main__":
s = Serverhttp()
Google Fan boy
--
http://mail.python.org/mailman/listinfo/python-list
EOF while scanning triple-quoted string literal
i've looked on the web and here but i didn't find an answer : here is my
code
zlib.decompress("""
xワᆳヤ=ラᄇHナs~Ʀᄑç\ムîà
z...@ÑÁÔqÇlxÇÆïpp~ývãì゙m6ÛÐ|ê֭ᄁᄂヤ=)}éÓUeö3ᄎᄌú"}ʿïÿ÷1þ8ñ́U÷ᄏñíLÒVi:`ᄈᄎL!Ê҆p6-%Fë^ヘ÷à,Q.K!ユô`ÄA!ÑêweÌ
ÊÚAロYøøÂjôóᅠÂcñ䊧fᆴùテúN
:nüzAÝ7%ᄌcdUタᄌ3ôPۂタlンyHᆲᄑ$/yzᄒíàヌ'ÕÓ&`|S!<'ᄂ÷Zļᄐ2ホモ;ニ(ÅÛfb!úü$ナテᄒ,9ßhàPᄎᄄێフÑbØὛホQᄍ-Ü}(n;ᄄホLヤ\^ï9ᆭᄍラDdВéÞ|åPOGᄂÐÙ%â&AÔë)ÎTÐC
ᄐïc枢í%Èï!フᄋëiq*ᄌVKÐNᄡ[ᄁfOq{OᆭÆÊ,0GᄂリmtツᄈOᄌΥ$#îヘqbYᄆメUニᄉÞáP`
ヨ×ᆵÃPwaレǩâ×)ハFcêÚ=!Åöᄊ
)AFñᄈ/cMᄃ!NóNΈór?pàÜòXw
Bvæ0ïçIÉoマ>5pᆭ-ØWÚNᄆùFᄆØPçÃþdᅠ;ル1[oᄈホ~6ツᄈᆬŕìᄄޠ=�...@ネvᄅ)÷%ユÜib{HᄆKŅVlDCテîfÑWì÷ìáár.ワîv゙OWラ|ÌbDᄁÖ녡M=Ð÷èâミム'ÂÝÐ
;ë mᄎQÂäԤۢ:モᄆdᄎᄑLȂ1ᄈ_÷YZᆲNòÛ
â\ロxÐlݵᆵムᆱøm5Ëá=ïoÍlMᆪ[×#Ypᅠトx[ÉÊyæツoモナz)ᆭᄀÝÏìò
""")
so it was a string that i got by zlib.compress an other string. How can i
decompress this string ? Regards Bussiere
Google Fan boy
--
http://mail.python.org/mailman/listinfo/python-list
Z39.50 and tyrannioware website seems to be down
Title: Z39.50 and tyrannioware website seems to be down sorry to disturb you but from here : http://lists.indexdata.dk/pipermail/zoom/2005-October/000806.html if yes i cannot take this three files : asn1.py z3950_2001.py zdefs.py the website seems to be down : http://cvs.sourceforge.net/viewcvs.py/tyrannioware/ may i ask you if someone always have these three files and if someone can mail me them , then ? Regards Bussiere -- http://mail.python.org/mailman/listinfo/python-list
documentation for the change of Python 2.5
I've read thsi documentation n: http://docs.python.org/dev/whatsnew/whatsnew25.html is there a way to have it in a more printable form ? Regards Bussiere -- http://mail.python.org/mailman/listinfo/python-list
Qrcode and python
Title: Qrcode and python I’am loooking for some information on qrcode module for python (making qrcode in python qrcode is a special kind of barcode) Or i only found japanese documentation If someone have english or french documentation i twill be nice Regards Bussiere I have some problems with this email and i dunnow if my old post i’ve been sent, if so excuse me -- http://mail.python.org/mailman/listinfo/python-list
making pseudo random number with spam ad convert text to binary
here is a little project to make a more or less good pseudo random generator by using spam :http://euryale.googlecode.com/it's almost quite finished but i've got a last problem i didn't manage to convert text to binary : hazard = binascii.a2b_qp(attachment) + binascii.a2b_qp(body) + binascii.a2b_qp(addr) + binascii.a2b_qp(sujet) print binascii.b2a_qp(hazard)it still print me ascii charactersregardsBussiere -- http://mail.python.org/mailman/listinfo/python-list
convert a long string in binary
i've got a very long string and i wanted to convert it in binary like string = """Monty Python, or The Pythons, is the collective name of the creators of Monty Python's Flying Circus, a British television comedy sketch show that first aired on the BBC on October 5, 1969. A total of 45 episodes were made over four series. However, the Python phenomenon was much greater, spawning stage tours, a musical, four films, numerous albums, and several books, as well as launching the members to individual stardom. The television series, broadcast by the BBC from 1969 to 1974, was conceived, written and performed by Graham Chapman, John Cleese (1969-1973), Terry Gilliam, Eric Idle, Terry Jones and Michael Palin. Loosely structured as a sketch show, but with a highly innovative stream-of-consciousness approach (aided by Terry Gilliam's animations), it pushed the boundaries of what was then considered acceptable, both in terms of style and content. """ string = binary(string) print string // 01010101010101 i 'am searching for something like the binary function (taht doesn't exist) to convert my string directly in binary. Regards Bussiere -- http://mail.python.org/mailman/listinfo/python-list
gadfly error gadfly instance has no attribute 'execute'
here is the error i've get :Traceback (most recent call last):
File "D:\Programmation\pitney\pitney.py", line 13, in ?
connection.execute('create table personne(nom varchar)')
AttributeError: gadfly instance has no attribute 'execute'i'am under windows and i still haven't found the errorhere is my code :import csv,gadfly,fileinput,glob, string, sys, os,unicodedata
print "que voulez vous faire ?\n"fichA=raw_input("Entrez le nom du fichier a importer : ")cr = csv.reader(open(fichA),delimiter=";")connection = gadfly.gadfly()connection.startup
('pitney','D:\Programmation\pitney\')cursor = connection.cursor()connection.execute('create table personne(nom varchar)')cursor.execute("insert into personne(nom) values('bussiere')")connection.commit
()cursor.execute('select * from personne')print cursor.fetchall()compteur = 0for row in cr: print row[0],row[1]compteur += 1print "Dead Parrot"regards Bussiere
--
http://mail.python.org/mailman/listinfo/python-list
very strange bug coercing to Unicode: need string or buffer, int found
i truly didn't understand this error :Traceback (most recent call last): File "D:\Programmation\FrancePaquet\FrancePaquet.py", line 77, in ? cabtri = "zz" + chiffrescabtri + clefcTypeError: coercing to Unicode: need string or buffer, int found
>>> if someone could help me i will be glad, this program worked yesterday.RegardsBussierehere is my program :import fileinput,stringdef calculclef(nombre): nombre2 = int(nombre)*10
nombre = str(nombre2) taille = len(nombre) compteur = 0 nombrepair = 0 nombreimpair = 0 compteur = taille - 2 while compteur != -1: print 'nombre :' print nombre[compteur] + '\n'
if compteur%2 : nombrepair = nombrepair + int(nombre[compteur]) print 'suite pair %d' % nombrepair else: nombreimpair = nombreimpair + int(nombre[compteur])
print 'suite impair %d' % nombreimpair print compteur = compteur - 1 print nombreimpair print nombrepair clef = nombrepair*3+nombreimpair clef = 10-(clef%10)
if clef == 10: clef = 0 return clefcompteclient = "8150"souscompteclient = "03"codeaffranc = "080"partielibre = "142391"print("LES CODES POSTAUX DOIVENT ETRE A LA FIN DU FICHIER CSV ! \n")
fichA=raw_input("Entrez le nom du fichier d'entree : ")print ("\n")fichC=raw_input("Entrez le nom du fichier de sortie : ")print ("\n")debutplage = raw_input("Entrez le numero du debut de plage : ")
print ("\n")finplage = raw_input("Entrez le numero de fin de plage : ")print ("\n") nbredeplage = int(debutplage) - int(finplage)fiA=open(fichA,"r")
fiC=open(fichC,"w")print calculclef(debutplage)compteur = 0debutplagewhile 1: fileencoding = "latin1" ligneA=fiA.readline() ligneA = ligneA.decode(fileencoding)
if ligneA == "": break if ligneA != "": stramettre = ligneA if compteur != 0: taille = len(ligneA) codepostal = ligneA[taille-5] + ligneA[taille-4] + ligneA[taille-3] + ligneA[taille-2]+ ligneA[taille-1]
print codepostal clefb = calculclef(debutplage) clefb = str(clefb) print clefb num = str(debutplage) cabsuivis = "8w"+ num + clefb
stramettre = stramettre + ";*" + cabsuivis + "*" chiffrescabtri = clefb + codepostal + compteclient + souscompteclient + codeaffranc + partielibre clefc = calculclef(chiffrescabtri)
cabtri = "zz" + chiffrescabtri + clefc stramettre = stramettre + ";*" + cabtri + "*" fiC.write(stramettre) compteur += 1
print compteur, "\n"print "FINIT"fiA.close()fiC.close()
--
http://mail.python.org/mailman/listinfo/python-list
deprecated python 2.5
DeprecationWarning: struct integer overflow masking is deprecated
return struct.pack('>H', ~value)
i didn't understand if someone have some explanation
and what uses instead.
--
http://mail.python.org/mailman/listinfo/python-list
Re: deprecated python 2.5
thks
Regards
Bussiere
On 9/12/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> bussiere maillist wrote:
>
> > DeprecationWarning: struct integer overflow masking is deprecated
> > return struct.pack('>H', ~value)
> > i didn't understand if someone have some explanation
> > and what uses instead.
>
> the value doesn't fit in 16 bits. try masking off the extra bits on the
> way in:
>
> struct.pack("
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
speech recognition linux and python
just for my hobby, i'am looking in a way to try voice recongnition on linux with python but with google i didn't find anything probant. By the way does someones can give me some tips or url to digg in this way particulary ? Is there anyway to use python for voice recognition on linux ? If yes with what ? Regards bussiere "speech recognition linux and python" -- http://mail.python.org/mailman/listinfo/python-list
python and a 2 gigs Usb Stick (pure pythonic stick)
Hi, i've received for my birthday two usb key, and i had the idea to make the 2GB one a special python usb key. So far i've put on it : Movable Python My Python directory Iron Python Jython Instant django the file installation for : Python , iron python , jython , PIL , Pygame , Pywin32 The pdf in a doc_programmation : dive into python , programmting python What else should i add in this key in your opinion ? Regards and thanks -- http://mail.python.org/mailman/listinfo/python-list
python and QRcode ?
i'am looking for some module and programs in ptyhon for making qrcode (special kind of barcode)But i only found documentation and programs in japanese.Does it exist program and documentation for python in qrcode in english ? regardsBussiere -- http://mail.python.org/mailman/listinfo/python-list
Re: include a file in a python program
Thanks all for your response i will try out this week, you have give
me sufficient hint.
Thanks again.
Bussiere
On Mon, Sep 6, 2010 at 9:50 AM, Niklasro(.appspot) wrote:
> On Sep 5, 10:57 pm, bussiere bussiere wrote:
>> i've got a python.txt that contain python and it must stay as it (python.txt)
>>
>> how can i include it in my program ?
>> import python.txt doesn't work
>> is there a way :
>> a) to make an include("python.txt")
>> b) tell him to treat .txt as .py file that i can make an import python ?
>> i'am using python3
>> Regards
>> Bussiere
>> fan of torchwood
>> Google Fan boy
>
> You can do it with tkinter to also enable GUI.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
