Re: HOW TO build object graph or get superclasses list for self.__class__ ?

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 3:35 PM, Dmitry Ponyatov fo...@km.ru wrote: Hello Help please with such problem: I need to build program object graph (data structure) with additional parameters for nodes and edges: include nxgraph # data structure module allowes any py objects for node/edge id #

Re: python glibc crypt() function

2010-04-21 Thread luca72
On 20 Apr, 19:38, Peter Otten __pete...@web.de wrote: luca72 wrote: Hello i have to do this : glibc crypt() function, using salt $1$abcdefgh$ cryptPw = crypt(plainPw, $1$abcdefgh$) Thanks The result is correct i obtain the same with ctypes and crypt module, so i think that is better to use

Re: Python DXF import library?

2010-04-21 Thread Justin Ezequiel
On Apr 20, 9:19 pm, Stodge sto...@gmail.com wrote: Is anyone aware of a Python DXF import library? I think I remember seeing converters but so far I haven't found a library. I need to write a tool that reads DXFs so I'm not yet sure if a converter would be of any use. Thanks

how to debug python application crashed occasionally

2010-04-21 Thread jacky wang
Hello recently, I met a problem with one python application running with python2.5 | debian/lenny adm64 system: it crashed occasionally in our production environment. The problem started to happen just after we upgraded the python application from python2.4 | debian/etch amd64. after

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Chris Rebert
On Tue, Apr 20, 2010 at 9:52 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Sebastian ba...@redtoad.de writes: All locales return error messages in English. Only the Japanese uses Japanese which my regular expressions cannot handle at the moment. What exactly are you expecting to happen,

Re: python glibc crypt() function

2010-04-21 Thread Peter Otten
luca72 wrote: On 20 Apr, 19:38, Peter Otten __pete...@web.de wrote: luca72 wrote: Hello i have to do this : glibc crypt() function, using salt $1$abcdefgh$ cryptPw = crypt(plainPw, $1$abcdefgh$) Thanks The result is correct i obtain the same with ctypes and crypt module, so i think

how does a queue stop the thread?

2010-04-21 Thread kaiix
A simple thread pool example. My question is, since *MyThread.run* will loop endless, how does the thread know the time to quit? how does the *queue* notify the thread? is there any shared variables, like a *lock*? When I set daemon false, it stays in the loop, not quit any more. what's the role

error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread fab
Hello. I read a string from an utf-8 file: fichierLaTeX = codecs.open(sys.argv[1], r, utf-8) s = fichierLaTeX.read() fichierLaTeX.close() I can then print the string without error with 'print s'. Next I parse this string: def parser(s): i = 0 while i len(s): if s[i:i+1] == '\\':

Re: Operations on sparse matrices

2010-04-21 Thread Helmut Jarausch
On 04/19/10 08:03, pp wrote: I am currently dealing with sparse matrices and have doubts on whether we can use 1.) dot (for matrix multiplication) and inv (inverse) operations of numpy on sparse matrices of CSR format. I don't know of any use of the inverse of a sparse matrix. Note, in

Re: how does a queue stop the thread?

2010-04-21 Thread Kushal Kumaran
On Wed, Apr 21, 2010 at 1:38 PM, kaiix kvn@gmail.com wrote: A simple thread pool example. My question is, since *MyThread.run* will loop endless, how does the thread know the time to quit? how does the *queue* notify the thread? is there any shared variables, like a *lock*? When I set

Re: how does a queue stop the thread?

2010-04-21 Thread Kushal Kumaran
On Wed, Apr 21, 2010 at 1:50 PM, Kushal Kumaran kushal.kumaran+pyt...@gmail.com wrote: On Wed, Apr 21, 2010 at 1:38 PM, kaiix kvn@gmail.com wrote: A simple thread pool example. My question is, since *MyThread.run* will loop endless, how does the thread know the time to quit? how does the

Re: Write web apps in Python?

2010-04-21 Thread Bruno Desthuilliers
Bryan a écrit : I think I see what you mean Err... -- correct me if I'm wrong: You are, sorry !-) You want to keep complex application data structures around between requests. Nope. I want to keep all my settings parsed, my librairies loaded, all my connections opened etc. That is,

Re: Is it better to extend a class, or do something repetitious in the main part of a program?

2010-04-21 Thread Vinay Sajip
On Apr 19, 3:45 pm, J dreadpiratej...@gmail.com wrote: First, before I get farther, Is there a way for theloggingmodule to natively handle lists and dict objects whenlogging? e.g. take this {'key1':'val1','key2':'val2'} and have it logged like this: INFO: key1: val1 INFO: key2: val2 If

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread Peter Otten
f...@slick.airforce-one.org wrote: Hello. I read a string from an utf-8 file: fichierLaTeX = codecs.open(sys.argv[1], r, utf-8) s = fichierLaTeX.read() fichierLaTeX.close() I can then print the string without error with 'print s'. Next I parse this string: def parser(s): i =

rfind bug ?

2010-04-21 Thread Stef Mientki
With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? thanks, Stef -- http://mail.python.org/mailman/listinfo/python-list

Re: rfind bug ?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? No. Don't you think someone would have found such an obvious bug by now? You want regular

Re: rfind bug ?

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 6:51 PM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? Python's documentation states: | rfind(...) | S.rfind(sub [,start [,end]]) - int | |

Re: rfind bug ?

2010-04-21 Thread Peter Otten
Chris Rebert wrote: [didn't see the original message] On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? No. Don't you think someone would have

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread fab
Change your string literals to unicode by adding the u-prefix and you should be OK. Thanks, it solved the problem... for a while! I need now to know if s[i] gives the next byte or the next character, when I scan the string s. I've googled pages about python and unicode, but didn't find a

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Sebastian
General advice with character sets in Python apply: always explicitly declare the encoding of input, then decode to Unicode interally as early as possible, and process all text that way. Only fix into an encoding when it's time to output. Maybe I was too vague when describing my problem. As

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 2:29 AM, f...@slick.airforce-one.org wrote: Change your string literals to unicode by adding the u-prefix and you should be OK. Thanks, it solved the problem... for a while! I need now to know if s[i] gives the next byte or the next character, when I scan the string

Re: Code redundancy

2010-04-21 Thread Jean-Michel Pichavant
Alan Harris-Reid wrote: Jean-Michel Pichavant wrote: Alan Harris-Reid wrote: Hi, During my Python (3.1) programming I often find myself having to repeat code such as... class1.attr1 = 1 class1.attr2 = 2 class1.attr3 = 3 class1.attr4 = 4 etc. Is there any way to achieve the same result

Re: how does a queue stop the thread?

2010-04-21 Thread kaiix
@kushal, thanks for your replies. before i wrote the email, i've already read the python docs carefully. i need the proof from code, i mean python source code. i tried to prove some of my assumptions that lead the loop quit, and i traced back to Queue.py, threading.py, dummy_thread.py, now i need

Re: Write web apps in Python?

2010-04-21 Thread Adam Tauno Williams
On Wed, 2010-04-21 at 10:28 +0200, Bruno Desthuilliers wrote: Bryan a écrit : I think I see what you mean Err... -- correct me if I'm wrong: You are, sorry !-) You want to keep complex application data structures around between requests. Nope. I want to keep all my

Re: rfind bug ?

2010-04-21 Thread Paul Rudin
Peter Otten __pete...@web.de writes: OP: you may be looking for a = a bb ccc a[::-1].find( ) 3 But you should be aware of the effeciency implications of doing this. a[::-1] constructs a new list. It's probably faster to do e.g.: len(a) - a.rfind(..) - 1 --

Re: deleting objects present in a list

2010-04-21 Thread Dave Angel
(For some reason you posted your response before the message you were replying to. That's called Top-posting, and is bad form on these mailing lists) Sandy wrote: Thanks for the replies. Terry, What does 'immediately' mean? I did a small test and here are the results. import psutil def

shove does not store data as expected

2010-04-21 Thread Alex
Dear all, I'm trying to use the shove module (http://pypi.python.org/pypi/shove) for a simple script. The script read a CSV file ad store the data. When I check the content of the store object (instance of Shove) *before* I close it, the data are all there but when I close and re- open it some

Re: rfind bug ?

2010-04-21 Thread Stef Mientki
On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this a bug ? No. Don't you think someone

Re: rfind bug ?

2010-04-21 Thread Peter Otten
Paul Rudin wrote: Peter Otten __pete...@web.de writes: OP: you may be looking for a = a bb ccc a[::-1].find( ) 3 But you should be aware of the effeciency implications of doing this. a[::-1] constructs a new list. A new string, yes. It's probably faster to do e.g.: len(a) -

Re: how does a queue stop the thread?

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 7:36 PM, kaiix kvn@gmail.com wrote: before i wrote the email, i've already read the python docs carefully. i need the proof from code, i mean python source code. i tried to prove some of my assumptions that lead the loop quit, and i traced back to Queue.py,

Re: Write web apps in Python?

2010-04-21 Thread Paul Rubin
Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid writes: Nope. I want to keep all my settings parsed, my librairies loaded, all my connections opened etc. That is, all the time consuming stuff at app startup - which, with PHP, mostly happens for each and every request. I thought

Re: Code redundancy

2010-04-21 Thread Andreas Löscher
You can do something like this: class A(): pass inst=A() exec( ... a=1 ... b=2 ... c=3 ... d=4 ... ) in inst.__dict__ inst.a 1 This executes the Statement in the exec function and uses inst.__dict__ as namespace. But be aware, that this is not recommended. If you mess with __dict__, you

Re: Write web apps in Python?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 2:33 AM, Adam Tauno Williams awill...@whitemice.org wrote: On Wed, 2010-04-21 at 10:28 +0200, Bruno Desthuilliers wrote: Bryan a écrit : I think I see what you mean Err... -- correct me if I'm wrong: You are, sorry !-) You want to keep complex application

Re: rfind bug ?

2010-04-21 Thread Jean-Michel Pichavant
Stef Mientki wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11 Is this

Re: rfind bug ?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki stef.mien...@gmail.com wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3' a.rfind(' ',7) 11

Re: rfind bug ?

2010-04-21 Thread Alf P. Steinbach
* Chris Rebert: On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki stef.mien...@gmail.com wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would expect a result of 5 !! a= 'word1 word2 word3'

Re: shove does not store data as expected

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 2:51 AM, Alex metallourla...@gmail.com wrote: I'm trying to use the shove module (http://pypi.python.org/pypi/shove) for a simple script. The script read a CSV file ad store the data. When I check the content of the store object (instance of Shove) *before* I close it,

Declarative programming for the Model part of an application

2010-04-21 Thread pca
Dear all, Last week, I raised the question Could declarative programming be useful for the Model part of an application ?, and I suggested an open-source project, Yoopf, to provide such a paradigm in Python. Stefan told me that the proposal lacked clarity. I have thus updated the description,

Tkinter question

2010-04-21 Thread Rotwang
Apologies in advance if this is a totally stupid question, I've tried looking at the Tkinter documentation on the web but since I'm something of an ignoramus when it comes to programming generally I didn't understand what I was reading. Anyway... I've written a module that allows me to

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread fab
Thanks for your insights. I have taken the easy way out, I read on a page that python 3 worked by default in UTF-8, so I downloaded and installed it. Apart from a few surprises (print is not a funtion, and rules about mixing spaces and tabs in indentation are much more strict, and I guess more

Re: rfind bug ?

2010-04-21 Thread Stef Mientki
On 21-04-2010 12:33, Alf P. Steinbach wrote: * Chris Rebert: On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki stef.mien...@gmail.com wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the following code, I would

Re: rfind bug ?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 3:33 AM, Alf P. Steinbach al...@start.no wrote: * Chris Rebert: On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki stef.mien...@gmail.com wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki stef.mien...@gmail.com wrote: With the

Re: Tkinter question

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 8:45 PM, Rotwang sg...@hotmail.co.uk wrote: def draw(self, w, h):        out = Tkinter.Canvas(width = w, height = h)        # a load of out.create_line(...)'s go here        out.pack()        out.mainloop() It works, but the problem is that I can't do anything else

Re: Re: Code redundancy

2010-04-21 Thread Alan Harris-Reid
Andreas Löscher wrote: You can do something like this: class A(): pass inst=) exec( ... a= ... b=2 ... c=3 ... d=4 ... ) in inst.__dict__ inst.a 1 This executes the Statement in the exec function and uses inst.__dict__ as namespace. But be aware, that this is

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Ben Finney
Sebastian ba...@redtoad.de writes: My regular expressions turn the Amazon error messages into Python exceptions. This works fine as long as they are in English: ??? is not a valid value for BrowseNodeId. Please change this value and retry your request., for instance, will raise an

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread Peter Otten
f...@slick.airforce-one.org wrote: I have taken the easy way out, I read on a page that python 3 worked by default in UTF-8, so I downloaded and installed it. Just a quick reminder: UTF-8 is not the same as unicode. Python3 works in unicode and by default uses UTF-8 to read from or write into

Re: shove does not store data as expected

2010-04-21 Thread Alex
On 21 Apr, 12:36, Chris Rebert c...@rebertia.com wrote: [cut] Explanation: The explicit assignment back to the `store` pseudo-dictionary lets it properly update its internal state to reflect the change to the value (in this case, the list) associated with the region key. In your original

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Sebastian
My regular expressions turn the Amazon error messages into Python exceptions. This works fine as long as they are in English: ??? is not a valid value for BrowseNodeId. Please change this value and retry your request., for instance, will raise an InvalidParameterValue exception.

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 4:46 AM, Sebastian ba...@redtoad.de wrote: My regular expressions turn the Amazon error messages into Python exceptions. This works fine as long as they are in English: ??? is not a valid value for BrowseNodeId. Please change this value and retry your request.,

socked and bytes operation

2010-04-21 Thread luca72
Hello i have this question : i connect to the server in this way: sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect(('192.168.1.11',11502)) rcv = sock.recv(8124) here i get 14 random bytes , in a string with strange chars like : ¬¨^.á‹•Ò a„ãj I think because sock.recv return a

Inline Calculation of Dictionary Values

2010-04-21 Thread ++imanshu
Hi, Is it possible to something along these lines in python :- map = { 'key1': f(), 'key2': modify_state(); val = f(); restore_state(); val, 'key3': f(), } For 'key2' I want to store the value returned by f() but after modifying the state. Do we have something like a bare block. I am

Re: socked and bytes operation

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 5:37 AM, luca72 lucabe...@libero.it wrote: Hello i have this question : i connect to the server in this way: sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect(('192.168.1.11',11502)) rcv = sock.recv(8124) here i get 14 random bytes , in a string

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread python
Hi Peter, Just a quick reminder: UTF-8 is not the same as unicode. Python3 works in unicode and by default uses UTF-8 to read from or write into files. I'm not the OP, but wanted to make sure I was fully understanding your point. Are you saying all open() calls in Python that read text

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 5:51 AM, ++imanshu himanshu.g...@gmail.com wrote:     Is it possible to something along these lines in python :- map = { 'key1': f(), 'key2': modify_state(); val = f(); restore_state(); val, 'key3': f(), }      For 'key2' I want to store the value returned by f()

Re: Write web apps in Python?

2010-04-21 Thread Bryan
Bruno Desthuilliers wrote: Nope. I want to keep all my settings parsed, my librairies loaded, all my connections opened etc. That is, all the time consuming stuff at app startup - which, with PHP, mostly happens for each and every request. O.K. I wasn't clear on your objection. As I said the

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread Peter Otten
pyt...@bdurham.com wrote: Are you saying all open() calls in Python that read text files, automatically convert UTF-8 content to Unicode in the same manner as the following might when using Python 2.6? codecs.open( fileName, mode='r', encoding='UTF8', ... ) That's what I meant to say, but

Re: python glibc crypt() function

2010-04-21 Thread geremy condra
On Wed, Apr 21, 2010 at 2:29 AM, luca72 lucabe...@libero.it wrote: On 20 Apr, 19:38, Peter Otten __pete...@web.de wrote: luca72 wrote: Hello i have to do this : glibc crypt() function, using salt $1$abcdefgh$ cryptPw = crypt(plainPw, $1$abcdefgh$) Thanks The result is correct i obtain

Re: Write web apps in Python?

2010-04-21 Thread Bruno Desthuilliers
Bryan a écrit : Bruno Desthuilliers wrote: Nope. I want to keep all my settings parsed, my librairies loaded, all my connections opened etc. That is, all the time consuming stuff at app startup - which, with PHP, mostly happens for each and every request. O.K. I wasn't clear on your

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread python
Hi Peter, Are you saying all open() calls in Python that read text files, automatically convert UTF-8 content to Unicode in the same manner as the following might when using Python 2.6? codecs.open( fileName, mode='r', encoding='UTF8', ... ) That's what I meant to say, but it's not

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread Dave Angel
++imanshu wrote: Hi, Is it possible to something along these lines in python :- map = { 'key1': f(), 'key2': modify_state(); val = f(); restore_state(); val, 'key3': f(), } For 'key2' I want to store the value returned by f() but after modifying the state. Do we have something like

Re: Write web apps in Python?

2010-04-21 Thread Tim Chase
On 04/21/2010 08:46 AM, Bruno Desthuilliers wrote: Bryan a écrit : Bruno Desthuilliers wrote: Many large, sopĥisticated etc applications are written in C. Does that make C a practical application programming language ? It's at least a strong clue. Oh, yes ? Then why don't you use C for web

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread ++imanshu
On Apr 21, 7:31 pm, Dave Angel da...@ieee.org wrote: ++imanshu wrote: Hi,      Is it possible to something along these lines in python :- map = { 'key1': f(), 'key2': modify_state(); val = f(); restore_state(); val, 'key3': f(), }       For 'key2' I want to store the value

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread ++imanshu
On Apr 21, 6:10 pm, Chris Rebert c...@rebertia.com wrote: On Wed, Apr 21, 2010 at 5:51 AM, ++imanshu himanshu.g...@gmail.com wrote:     Is it possible to something along these lines in python :- map = { 'key1': f(), 'key2': modify_state(); val = f(); restore_state(); val, 'key3': f(),

Re: Tkinter question

2010-04-21 Thread eb303
On Apr 21, 12:45 pm, Rotwang sg...@hotmail.co.uk wrote: Apologies in advance if this is a totally stupid question, I've tried looking at the Tkinter documentation on the web but since I'm something of an ignoramus when it comes to programming generally I didn't understand what I was reading.

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread Peter Otten
Dave Angel wrote: ++imanshu wrote: Hi, Is it possible to something along these lines in python :- map = { 'key1': f(), 'key2': modify_state(); val = f(); restore_state(); val, 'key3': f(), } For 'key2' I want to store the value returned by f() but after modifying the

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Terry Reedy
On 4/21/2010 7:46 AM, Sebastian wrote: The Amazon API returns an XML response which contains error messages if a request fails. These messages consist of an error code and an error description in natural language. Luckily, the description seems to stick to the same format and is (in all but one

Re: Japanese (speaking) developer needed for a bit of regex magic

2010-04-21 Thread Terry Reedy
On 4/21/2010 5:31 AM, Sebastian wrote: This works fine as long as they are in English: ??? is not a valid value for BrowseNodeId. Please change this value and retry your request., for instance, will raise an InvalidParameterValue exception. However, the Japanese version returns the error

Re: error when printing a UTF-8 string (python 2.6.2)

2010-04-21 Thread Terry Reedy
On 4/21/2010 9:29 AM, Peter Otten wrote: pyt...@bdurham.com wrote: Are you saying all open() calls in Python that read text files, automatically convert UTF-8 content to Unicode in the same manner as the following might when using Python 2.6? codecs.open( fileName, mode='r', encoding='UTF8',

xml.dom.minidom character encoding

2010-04-21 Thread C. Benson Manica
I have the following simple script running on 2.5.2 on a machine where the default character encoding is ascii: #!/usr/bin/env python #coding: utf-8 import xml.dom.minidom import codecs str=u?xml version=\1.0\ encoding=\utf-8\?elementselem attrib= \ó\//elements doc=xml.dom.minidom.parseString(

Re: xml.dom.minidom character encoding

2010-04-21 Thread Peter Otten
C. Benson Manica wrote: I have the following simple script running on 2.5.2 on a machine where the default character encoding is ascii: #!/usr/bin/env python #coding: utf-8 import xml.dom.minidom import codecs str=u?xml version=\1.0\ encoding=\utf-8\?elementselem attrib=

Re: xml.dom.minidom character encoding

2010-04-21 Thread C. Benson Manica
On Apr 21, 1:58 pm, Peter Otten __pete...@web.de wrote: C. Benson Manica wrote: (snip) It seems that parseString() doesn't like unicode Yes, I noticed that, and I already tried... -- let's try a byte string then: doc = xml.dom.minidom.parseString(s.encode(utf-8)) xml =

Re: socked and bytes operation

2010-04-21 Thread John Nagle
luca72 wrote: Hello i have this question : i connect to the server in this way: sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect(('192.168.1.11',11502)) rcv = sock.recv(8124) here i get 14 random bytes , in a string with strange chars like : ¬¨^.á‹•Ò a„ãj I think because

Re: xml.dom.minidom character encoding

2010-04-21 Thread Peter Otten
C. Benson Manica wrote: On Apr 21, 1:58 pm, Peter Otten __pete...@web.de wrote: C. Benson Manica wrote: (snip) It seems that parseString() doesn't like unicode Yes, I noticed that, and I already tried... -- let's try a byte string then: doc =

Re: Write web apps in Python?

2010-04-21 Thread Bryan
Bruno Desthuilliers wrote: Bryan a écrit : Bruno Desthuilliers wrote: Nope. I want to keep all my settings parsed, my librairies loaded, all my connections opened etc. That is, all the time consuming stuff at app startup - which, with PHP, mostly happens for each and every request.

Re: xml.dom.minidom character encoding

2010-04-21 Thread C. Benson Manica
On Apr 21, 2:25 pm, Peter Otten __pete...@web.de wrote: Are you sure that your script has str = u... like in your post and not just str = ... No :-) str=u?xml version=\1.0\ encoding=\utf-8\?elementselem attrib= \ó\//elements doc=xml.dom.minidom.parseString( str.encode(utf-8) )

Re: xml.dom.minidom character encoding

2010-04-21 Thread Peter Otten
C. Benson Manica wrote: On Apr 21, 2:25 pm, Peter Otten __pete...@web.de wrote: Are you sure that your script has str = u... like in your post and not just str = ... No :-) str=u?xml version=\1.0\ encoding=\utf-8\?elementselem attrib= \ó\//elements

Re: Write web apps in Python?

2010-04-21 Thread Emile van Sebille
On 4/21/2010 11:37 AM Bryan said... 'Round here we love Python. I prefer Python to Perl or PHP even in those languages' particular areas of specialization. Advocating for Python does not require spreading myths about PHP. You're missing the point -- set-up and tear-down overhead is involved

Re: Usable street address parser in Python?

2010-04-21 Thread Albert van der Horst
In article 4bcddc5a$0$1630$742ec...@news.sonic.net, John Nagle na...@animats.com wrote: Iain King wrote: Not sure on the volume of addresses you're working with, but as an alternative you could try grabbing the zip code, looking up all addresses in that zip code, and then finding whatever one

ctypes errcheck question

2010-04-21 Thread Brendan Miller
According to the ctypes docs: http://docs.python.org/library/ctypes.html An errcheck function should return the args tuple when used with out parameters (section 15.15.2.4. Function prototypes). However, in other cases it says to return the result, or whatever result you want returned from the

Deleting more than one element from a list

2010-04-21 Thread candide
Is the del instruction able to remove _at the same_ time more than one element from a list ? For instance, this seems to be correct : z=[45,12,96,33,66,'c',20,99] del z[2], z[6],z[0] z [12, 33, 66, 'c', 20] However, the following doesn't work :

Re: Deleting more than one element from a list

2010-04-21 Thread Simon Brunning
On 21 April 2010 20:56, candide cand...@free.invalid wrote: Is the del instruction able to remove _at the same_ time more than one element from a list ? Yup: z=[45,12,96,33,66,'c',20,99] del z[:] z [] -- Cheers, Simon B. -- http://mail.python.org/mailman/listinfo/python-list

Re: Deleting more than one element from a list

2010-04-21 Thread Gary Herron
candide wrote: Is the del instruction able to remove _at the same_ time more than one element from a list ? For instance, this seems to be correct : z=[45,12,96,33,66,'c',20,99] del z[2], z[6],z[0] z [12, 33, 66, 'c', 20] However, the following doesn't work :

Re: Deleting more than one element from a list

2010-04-21 Thread Mensanator
On Apr 21, 2:56 pm, candide cand...@free.invalid wrote: Is the del instruction able to remove _at the same_ time more than one element from a list ? For instance, this seems to be correct :   z=[45,12,96,33,66,'c',20,99]   del z[2], z[6],z[0]   z [12, 33, 66, 'c', 20]  

Re: Deleting more than one element from a list

2010-04-21 Thread Emile van Sebille
On 4/21/2010 12:56 PM candide said... Is the del instruction able to remove _at the same_ time more than one element from a list ? For instance, this seems to be correct : z=[45,12,96,33,66,'c',20,99] Not as I see it -- watch your index values - they change after each delete is

Windows debugging symbols for python 2.5.4 and pywin32 214

2010-04-21 Thread Alexandre Fayolle
Hi everyone, I have a production server running a Windows Service written in Python, which uses python 2.5.4 (yes I know it is old, but I am somewhat stuck with this for now) and pywin32 214. Given a set of manipulations, I get a stack overflow in the service, and a bad crash. The same

Looking for registration package

2010-04-21 Thread kj
I'm looking for a Python-based, small, self-contained package to hand out API keys, in the same spirit as Google API keys. The basic specs are simple: 1) enforce the one key per customer rule; 2) be robot-proof; 3) be reasonably difficult to circumvent even for humans. (This is for a web

ctypes: delay conversion from c_char_p to string

2010-04-21 Thread Brendan Miller
I have a function exposed through ctypes that returns a c_char_p. Since I need to deallocate that c_char_p, it's inconvenient that ctypes copies the c_char_p into a string instead of giving me the raw pointer. I believe this will cause a memory leak, unless ctypes is smart enough to free the

Python-URL! - weekly Python news and links (Mar 9)

2010-04-21 Thread Cameron Laird
QOTW: I used to think anonymous functions (AKA blocks, etc...) would be a nice feature for Python. Then I looked at a stack trace from a different programming language with lots of anonymous functions. (I believe it was perl.) I became enlightened. - Jonathan Gardner, apparently echoing Guido's

Python-URL! - weekly Python news and links (Mar 17)

2010-04-21 Thread Cameron Laird
QOTW: ... [T]hat kills yet another usage of C ... - Maciej Fijalkowski http://morepypy.blogspot.com/2009/11/some-benchmarking.html Making operations in the Fraction class automatically return a subclass instance when called with subclass arguments:

Python-URL! - weekly Python news and links (Feb 9)

2010-04-21 Thread Cameron Laird
QOTW: You see? That's what I like about the Python community: people even apologise for apologising :) - Tim Golden http://groups.google.com/group/comp.lang.python/msg/858d1c31d0c2adff The third alpha version of Python 2.7 is ready for testing:

Re: ctypes: delay conversion from c_char_p to string

2010-04-21 Thread Brendan Miller
Here's the method I was using. Note that tmp_char_ptr is of type c_void_p. This should avoid the memory leak, assuming I am interpreting the semantics of the cast correctly. Is there a cleaner way to do this with ctypes? def get_prop_string(self, prop_name): # Have to work with

Re: Code redundancy

2010-04-21 Thread Ryan Kelly
On Tue, 2010-04-20 at 14:43 +0100, Alan Harris-Reid wrote: Hi, During my Python (3.1) programming I often find myself having to repeat code such as... class1.attr1 = 1 class1.attr2 = 2 class1.attr3 = 3 class1.attr4 = 4 etc. Is there any way to achieve the same result without having

Re: Deleting more than one element from a list

2010-04-21 Thread candide
Thanks for your reponses. -- http://mail.python.org/mailman/listinfo/python-list

Python-URL! - weekly Python news and links (Apr 21)

2010-04-21 Thread Cameron Laird
QOTW: There's no RightAnswer(tm), just our best guess as to what is the most useful behavior for the most number of people. - Raymond Hettinger http://groups.google.com/group/comp.lang.python/msg/e7f78ef27811781b First beta version of Python 2.7 is available:

Re: Code redundancy

2010-04-21 Thread Alan Harris-Reid
Ryan Kelly wrote: On Tue, 2010-04-20 at 14:43 +0100, Alan Harris-Reid wrote: Hi, During my Python (3.1) programming I often find myself having to repeat code such as... class1.attr1 = 1 class1.attr2 = 2 class1.attr3 = 3 class1.attr4 = 4 etc. Is there any way to achieve the same result

withhacks module (Re: Code redundancy)

2010-04-21 Thread python
Ryan, Your withhacks module looks very interesting. http://pypi.python.org/pypi/withhacks What are your specific concerns about its use? Are there portability concerns? Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: withhacks module (Re: Code redundancy)

2010-04-21 Thread Ryan Kelly
On Wed, 2010-04-21 at 19:43 -0400, pyt...@bdurham.com wrote: Ryan, Your withhacks module looks very interesting. http://pypi.python.org/pypi/withhacks What are your specific concerns about its use? Are there portability concerns? It combines two things you just don't see in respectable

Re: when should I explicitly close a file?

2010-04-21 Thread Lawrence D'Oliveiro
In message 4bc9aad...@dnews.tpgi.com.au, Lie Ryan wrote: Since in python nothing is guaranteed about implicit file close ... It is guaranteed that objects with a reference count of zero will be disposed. In my experiments, this happens immediately. --

Re: Download Proprietary Microsoft Products Now

2010-04-21 Thread Lawrence D'Oliveiro
In message mailman.1949.1271443668.23598.python-l...@python.org, Martin v. Löwis wrote: Brian Blais wrote: On Apr 12, 2010, at 16:36 , Martin v. Loewis is wrote: If you are planning to build Python extension modules in the next five years, I recommend that you obtain a copy of VS Express

Re: when should I explicitly close a file?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 5:53 PM, Lawrence D'Oliveiro wrote: In message 4bc9aad...@dnews.tpgi.com.au, Lie Ryan wrote: Since in python nothing is guaranteed about implicit file close ... It is guaranteed that objects with a reference count of zero will be disposed. In my experiments, this

  1   2   3   >