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

2010-04-21 Thread Sebastian
> > 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 message "??? > > は、

Re: socked and bytes operation

2010-04-21 Thread luca72
On 21 Apr, 20:42, John Nagle wrote: > 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

Re: Download Proprietary Microsoft Products Now

2010-04-21 Thread Martin v. Loewis
>> ... or because Mingw32 doesn't provide the header files (in particular >> wrt. C++), or because linking with a library is necessary that uses the >> MSVC mangling, not the g++ one (again, for C++). > > Again, that would be code that’s not portable off Windows. Probably (although it *is* possib

Re: Download Proprietary Microsoft Products Now

2010-04-21 Thread Martin v. Loewis
>> ... or because Mingw32 doesn't provide the header files (in particular >> wrt. C++), or because linking with a library is necessary that uses the >> MSVC mangling, not the g++ one (again, for C++). > > Again, that would be code that’s not portable off Windows. Probably (although it *is* possib

Re: when should I explicitly close a file?

2010-04-21 Thread Alf P. Steinbach
* 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. Only in current CPython. In my experiments, this happens i

Re: xml.dom.minidom character encoding

2010-04-21 Thread Stefan Behnel
C. Benson Manica, 21.04.2010 19:19: 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"" doc=xml.dom.minidom.parseString( str ) xml=doc.toxml( encoding

PyCon Australia 2010 update

2010-04-21 Thread Richard Jones
Hi everyone, Here's some updates for PyCon Australia 2010, to be held at the Sydney Masonic Center over the weekend of June 26 and 27. 1. Registration is now open 2. Keynotes announced 3. Call For Proposals proceeds 4. Several sponsors confirmed Please pass this message on to those you feel will

Re: when should I explicitly close a file?

2010-04-21 Thread Steven D'Aprano
On Thu, 22 Apr 2010 12:53:51 +1200, 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. Not all Pyth

MAKE A TON OF MONEY!!!

2010-04-21 Thread Krushbrook
A little while back, I was browsing these newsgroups, just like you are now, and came across an article similar to this that said you could make thousands of dollars within weeks with only an initial investment of $5.00 ! So I thought, "Yeah, right, this must be a scam", like most of us, b

Re: Download Proprietary Microsoft Products Now

2010-04-21 Thread David Cournapeau
On Thu, Apr 22, 2010 at 9:59 AM, Lawrence D'Oliveiro wrote: >> ... or because Mingw32 doesn't provide the header files (in particular >> wrt. C++), or because linking with a library is necessary that uses the >> MSVC mangling, not the g++ one (again, for C++). > > Again, that would be code that’s

Re: Download Proprietary Microsoft Products Now

2010-04-21 Thread Lawrence D'Oliveiro
In message <4bc8547...@dnews.tpgi.com.au>, Lie Ryan wrote: > ... so you should get the full installer if you want to insure yourself > from Microsoft pulling the plug out. I wonder how many Windows users will be able to figure that out... -- http://mail.python.org/mailman/listinfo/python-list

Re: withhacks module (Re: Code redundancy)

2010-04-21 Thread python
Ryan, > So if you don't care about portability or about that dirty feeling you get > from messing with the Python internals, then have at it :-) Warnings aside, its very clever code. Thanks for sharing! Malcolm -- http://mail.python.org/mailman/listinfo/python-list

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

Re: Download Proprietary Microsoft Products Now

2010-04-21 Thread Lawrence D'Oliveiro
In message , "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 >> >> Am I missing something here? I

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. -- http://mail.python.org/mailman/listinfo

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 respec

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: 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 wi

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: http://groups.google.

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

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 wit

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 c_void_

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: http://groups.google.com/group/comp

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: http://groups.google.com/grou

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'

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 string

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 se

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 opera

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 co

Re: Deleting more than one element from a list

2010-04-21 Thread Mensanator
On Apr 21, 2:56 pm, 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] >  >>> > > Howe

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 : >> z=

Re: Deleting more than one element from a list

2010-04-21 Thread Simon Brunning
On 21 April 2010 20:56, candide 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

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 : >> z=[45,12,96,33,66,

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 fun

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 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 of those

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 fo

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" \"ó\"/>" > doc=xml.dom.minidom.parseString( str.encode("utf-8") ) > xml=doc.

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"" doc=xml.dom.minidom.parseString( str.encode("utf-8") ) xml=doc.toxml( encoding="utf-8") file=codecs.open( "foo.xml", "w

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 re

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 = xml.dom.minido

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 sock.

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")) > >>> xm

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" \"ó\"/>" > doc=xml.dom.minidom.parseString( str ) > xml=

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"" doc=xml.dom.minidom.parseString( str ) xml=doc.toxml( encoding="utf-8" ) file=codecs.open( "foo.xml"

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', .

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 err

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: 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 afte

Re: Tkinter question

2010-04-21 Thread eb303
On Apr 21, 12:45 pm, Rotwang 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. Anyway... > > I'v

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread ++imanshu
On Apr 21, 6:10 pm, Chris Rebert wrote: > On Wed, Apr 21, 2010 at 5:51 AM, ++imanshu 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

Re: Inline Calculation of Dictionary Values

2010-04-21 Thread ++imanshu
On Apr 21, 7:31 pm, 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

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 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: 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

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 objection.

Re: python glibc crypt() function

2010-04-21 Thread geremy condra
On Wed, Apr 21, 2010 at 2:29 AM, 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 t

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,

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: Inline Calculation of Dictionary Values

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 5:51 AM, ++imanshu 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() but after > modi

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 file

Re: socked and bytes operation

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 5:37 AM, 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 char

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 a

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 st

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 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.",

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 > > ex

Re: shove does not store data as expected

2010-04-21 Thread Alex
On 21 Apr, 12:36, Chris Rebert 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 version, you me

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 int

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

2010-04-21 Thread Ben Finney
Sebastian 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 InvalidParameterVa

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

Re: Tkinter question

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 8:45 PM, Rotwang 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 with IDLE unti

Re: rfind bug ?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 3:33 AM, Alf P. Steinbach wrote: > * Chris Rebert: >> On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki >> wrote: >>> On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki wrote: > > With the following code, I would expect a

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 >> wrote: >>> On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki wrote: > With the following code, I would expect a result of 5 !!

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 is

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 manipul

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, a

Re: shove does not store data as expected

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 2:51 AM, Alex 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, the data are all th

Re: rfind bug ?

2010-04-21 Thread Alf P. Steinbach
* Chris Rebert: On Wed, Apr 21, 2010 at 2:59 AM, Stef Mientki wrote: On 21-04-2010 10:56, Chris Rebert wrote: On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki 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'

Re: rfind bug ?

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

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 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

Re: Write web apps in Python?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 2:33 AM, Adam Tauno Williams 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 appli

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 w

Re: Write web apps in Python?

2010-04-21 Thread Paul Rubin
Bruno Desthuilliers 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 we have WSGI for this? Nothing stops

Re: how does a queue stop the thread?

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 7:36 PM, kaiix 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, threading.py, dummy_th

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 f

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 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 s

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 da

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 tes

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 -- http://mail.pyt

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

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: 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 with

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, 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 s. I've googled pa

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. A

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 sol

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 > 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: rfind bug ?

2010-04-21 Thread James Mills
On Wed, Apr 21, 2010 at 6:51 PM, Stef Mientki 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 | | Return

Re: rfind bug ?

2010-04-21 Thread Chris Rebert
On Wed, Apr 21, 2010 at 1:51 AM, Stef Mientki 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 str.find(), which s

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: 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 pa

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 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 I pass the dict

  1   2   >