KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
I have problems in getting a SocketServer to shutdown. Why does this not actually stop the application? from SocketServer import UnixStreamServer, BaseRequestHandler server = UnixStreamServer('/tmp/ss.sock', BaseRequestHandler) try: server.serve_forever() except KeyboardInterrupt: server.

Re: x.abc vs x['abc']

2009-05-15 Thread alex23
On May 14, 5:49 am, Gunter Henriksen wrote: > Presuming it is very common to have objects created > on the fly using some sort of external data > definitions, is there an obvious common standard > way to take a dict object and create an object > whose attribute names are the keys from the dict? I

File System Redirection Windows x 64 box.

2009-05-15 Thread Rohit Srivastava
Hi, In Windows 2003 x64, I want to call iscsicli.exe which is there only in system32 directory. Now since in x64 system windows actually redirect the 32 bit application to sysWOW64 directory, if it is looking for system32. For more information look for

Re: (Windows) Finding out which process has locked a file.

2009-05-15 Thread CinnamonDonkey
I have to say, this has got to be one of the least helpful groups I am subscribed to. Some interesting links... http://support.microsoft.com/kb/218965 http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html#the-short-version http://timgolden.me.uk/python/win32_how_do_

Re: (Windows) Finding out which process has locked a file.

2009-05-15 Thread Tim Golden
CinnamonDonkey wrote: > I have to say, this has got to be one of the > least helpful groups I am subscribed to. I'm genuinely surprised to hear you say that, especially about this thread to which you (who appear to be the OP) have received several replies all pointing you towards the sysinternals

How to catch str exception?

2009-05-15 Thread anuraguni...@yahoo.com
import sys try: raise "xxx" except str,e: print "1",e # is not caught here except:# is caught here print "2",sys.exc_type,sys.exc_value In the above code a string exception is raised which though deprecated but still a 3rd party library I use uses it. So how can I catch such exception

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Lawrence D'Oliveiro
In message , Igor Katson wrote: > I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? I want the server close the socket, and the program to continue after that (in this case, just to terminate). -- http://mai

[ANN] BPT (Boxed Package Tool) 0.4a -- now with PIP support

2009-05-15 Thread Giuseppe Ottaviano
Hi all, I am happy to announce BPT 0.4a http://pypi.python.org/pypi/bpt This release is particularly interesting for python users, since it includes a modified version of PIP that installs the packages inside the box. So, at least for python packages, installation (including dependency res

Re: File System Redirection Windows x 64 box.

2009-05-15 Thread Rohit Srivastava
On May 15, 12:05 pm, Rohit Srivastava wrote: > Hi, > > In Windows 2003 x64, I want to call iscsicli.exe which is there only > in system32 directory. > Now since in x64 system windows actually redirect the 32 bit > application to sysWOW64 directory, if it is looking for system32. For > more informa

Re: How to catch str exception?

2009-05-15 Thread Kurt Symanzik
"anuraguni...@yahoo.com" wrote on 2009-05-15 4:13:15 PM +0800 import sys try: raise "xxx" except str,e: print "1",e # is not caught here except:# is caught here print "2",sys.exc_type,sys.exc_value In the above code a string exception is raised which though deprecated but still a 3r

Re: introspection question: get return type

2009-05-15 Thread Bruno Desthuilliers
Aahz a écrit : In article <4a0c6e42$0$12031$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Marco Mariani a écrit : Bruno Desthuilliers wrote: Oh, you meant the "return type" ? Nope, no way. It just doesn't make sense given Python's dynamic typing. Unless he's really trying to write in N

Re: urllib2 slow for multiple requests

2009-05-15 Thread Tomas Svarovsky
On May 14, 6:33 pm, "Richard Brodie" wrote: > "Tomas Svarovsky" wrote in message > > news:747b0d4f-f9fd-4fa6-bb6d-0a4365f32...@b1g2000vbc.googlegroups.com... > > > This is a good point, but then it would manifest regardless of the > > language used AFAIK. And this is not the case, ruby and php >

Re: How to catch str exception?

2009-05-15 Thread anuraguni...@yahoo.com
but the whole point of catching such exception is that i can print its value there are many such exceptions and hence it is not feasible to catch them all or know them all unless i go thru src code. -- http://mail.python.org/mailman/listinfo/python-list

test 23213213

2009-05-15 Thread Zainescu Traian
test test -- http://mail.python.org/mailman/listinfo/python-list

Re: (Windows) Finding out which process has locked a file.

2009-05-15 Thread CinnamonDonkey
Thanx for the response Tim! :-) Great site! > I'm genuinely surprised to hear you say that... Early morning frustration... I appologise to all... you are totally right. Thank you to all for the responses. The sysinternal "Handle" tool that you made reference to earlier is definately a working s

Re: How to catch str exception?

2009-05-15 Thread Peter Otten
anuraguni...@yahoo.com wrote: > but the whole point of catching such exception is that i can print its > value > there are many such exceptions and hence it is not feasible to catch > them all or know them all unless i go thru src code. Catch them all with a bare except and then reraise non-strin

Re: How to catch str exception?

2009-05-15 Thread anuraguni...@yahoo.com
> try: >     raise "abc" > except: >     e, t, tb = sys.exc_info() >     if not isinstance(e, str): >         raise >     print "caught", e This seems to be the solution, thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Lawrence D'Oliveiro
In message , Igor Katson wrote: > Lawrence D'Oliveiro wrote: > >> In message , Igor >> Katson wrote: >> >>> I have problems in getting a SocketServer to shutdown. >> >> Do you want to do a shutdown or a close? >> > I want the server close the socket ... You want to do a close, do a close,

Just wondering

2009-05-15 Thread Gediminas Kregzde
Hello, I'm Vilnius college II degree student and last semester our teacher introduced us to python I've used to program with Delphi, so I very fast adopted to python Now I'm developing cross platform program and use huge amounts of data. Program is needed to run as fast as it coud. I've read all

Re: KeyboardInterrupt catch does not shut down the socketserver

2009-05-15 Thread Igor Katson
Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: Lawrence D'Oliveiro wrote: In message , Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a close? I want the server close the socket ...

Re: itertools question

2009-05-15 Thread pataphor
Neal Becker wrote: Is there any canned iterator adaptor that will transform: in = [1,2,3] into: out = [(1,2,3,4), (5,6,7,8),...] That is, each time next() is called, a tuple of the next N items is returned. Here's one that abuses a for loop: from itertools import islice def grouper(

Re: Just wondering

2009-05-15 Thread bearophileHUGS
Gediminas Kregzde: > map function is slower than > for loop for about 5 times, when using huge amounts of data. > It is needed to perform some operations, not to return data. Then you are using map() for the wrong purpose. map() purpose is to build a list of things. Use a for loop. Bye, bearophil

Re: Just wondering

2009-05-15 Thread Stef Mientki
and this, while it's realy doing something is even 4 times faster than main2 ;-) And if you only need integers, it can be even faster. def main3(): from numpy import zeros t = time() a = zeros ( 1000 ) b = a + 3.14 print "loop time: " + str(time() - t) cheers, Stef Gediminas Kreg

Re: Just wondering

2009-05-15 Thread Marco Mariani
Gediminas Kregzde wrote: def doit(i): pass def main(): a = [0] * 1000 t = time() map(doit, a) print "map time: " + str(time() - t) Here you are calling a function ten million times, build a list with of ten million None results, then throw it away. def main2(): t =

Re: capture stdout and stderror from within a Windows Service?

2009-05-15 Thread Chris Curvey
On May 14, 11:57 am, Chris Curvey wrote: > I'm trying to get this invocation right, and it is escaping me.  How > can I capture the stdout and stderr if I launch a subprocess using > subprocess.check_call()?  The twist here is that the call is running > from within a Windows service. > > I've tri

Re: Just wondering

2009-05-15 Thread Jaime Fernandez del Rio
map is creating a new list of 10,000,000 items, not modifying the values inside list a. That's probably where your time difference comes from... Jaime On Fri, May 15, 2009 at 1:56 PM, Gediminas Kregzde wrote: > Hello, > > I'm Vilnius college II degree student and last semester our teacher > intr

Configure options for minimal Python 2.6

2009-05-15 Thread Andrew Malcolmson
I want to compile a minimal Python 2.6 for Debian Etch without support for optional features such as tk and sphinx. The configure script's help says that features can be disabled with an '--without-PACKAGE', so I guess disabling tk is '--without-tk', but where is there a list of the feature/packag

Re: Just wondering

2009-05-15 Thread Peter Otten
Gediminas Kregzde wrote: > Now I'm developing cross platform program and use huge amounts of > data. Program is needed to run as fast as it coud. I've read all tips > about geting performance, but got 1 bug: map function is slower than > for loop for about 5 times, when using huge amounts of data.

Re: creating python code with dynamic file name

2009-05-15 Thread Dave Angel
bijoy franco wrote: hi, How can i create python code, for which filename can be defined on the fly..? for example, in a blog, when each article selected, respective python code with headline of the article as filename should be called. thanks bijoy You could have been much clearer in yo

Re: Just wondering

2009-05-15 Thread Jaime Fernandez del Rio
> (1) building another throwaway list and > (2) function call overhead for calling doit() > > You can avoid (1) by using filter() instead of map() Are you sure of this? My python returns, when asked for help(filter) : Help on built-in function filter in module __builtin__: filter(...) filter

Re: Just wondering

2009-05-15 Thread Bruno Desthuilliers
Gediminas Kregzde a écrit : Hello, I'm Vilnius college II degree student and last semester our teacher introduced us to python I've used to program with Delphi, so I very fast adopted to python Now I'm developing cross platform program and use huge amounts of data. Program is needed to run as f

Re: File System Redirection Windows x 64 box.

2009-05-15 Thread Dave Angel
Rohit Srivastava wrote: Hi, In Windows 2003 x64, I want to call iscsicli.exe which is there only in system32 directory. Now since in x64 system windows actually redirect the 32 bit application to sysWOW64 directory, if it is looking for system32. For more information look for

Re: Just wondering

2009-05-15 Thread Peter Otten
Jaime Fernandez del Rio wrote: >> (1) building another throwaway list and >> (2) function call overhead for calling doit() >> >> You can avoid (1) by using filter() instead of map() > > Are you sure of this? > I'm afraid there is no builtin function to do an inplace modification > of a sequence

Re: capture stdout and stderror from within a Windows Service?

2009-05-15 Thread Tim Golden
Chris Curvey wrote: Ahhh, Blake put me on the right track. If you want any of the streams, you have to supply values for all of them, like so: p = subprocess.Popen(step, shell=True stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.com

Re: Your Favorite Python Book

2009-05-15 Thread Evan Kroske
Sam Tregar wrote: Greetings. I'm working on learning Python and I'm looking for good books to read. I'm almost done with Dive into Python and I liked it a lot. I found Programming Python a little dry the last time I looked at it, but I'm more motivated now so I might return to it. What's your

Re: Representing a Tree in Python

2009-05-15 Thread Jaime Fernandez del Rio
If you run Dijkstra without a third argument, i.e. without an end node, the it will compute the shortest paths from your start node to all nodes in the tree. So by doing something like: start_node = 1 end_nodes = [2,3,5] D, P = Dijkstra(G, start_node) You will then have in D a dictionary with di

Re: How to catch str exception?

2009-05-15 Thread Dave Angel
anuraguni...@yahoo.com wrote: import sys try: raise "xxx" except str,e: print "1",e # is not caught here except:# is caught here print "2",sys.exc_type,sys.exc_value In the above code a string exception is raised which though deprecated but still a 3rd party library I use uses it. So

Re: New to python, can i ask for a little help? (Andrew Chung)

2009-05-15 Thread Gabor Urban
I gues, it was rather simple... Begin with simple tasks, figure out how to do them. If you are proceding well, then increase difficulty/complexity. Gabor -- Linux: Choice of a GNU Generation -- http://mail.python.org/mailman/listinfo/python-list

Re: DOM implementation

2009-05-15 Thread Emanuele D'Arrigo
Hey Paul, would you mind continuing this thread on Python + DOM? I'm trying to implement a DOM Events-like set of classes and I could use another brain that has some familiarity with the DOM to bounce ideas with. If you are too busy never mind. Also, I thought of keeping the discussion here rather

Re: mod_python and xml.dom.minidom

2009-05-15 Thread dpapathanasiou
> Were you getting this issue with xml.dom showing on first request all > the time, or only occasionally occurring? If the latter, were you > running things in a multithreaded configuration and was the server > being loaded with lots of concurrent requests? It was the former. > For your particul

python

2009-05-15 Thread anica_1069
hello, I´m a student of linguistic an I need do this exercises. Can anybody help me,please? Thanks ◑ Read in some text from a corpus, tokenize it, and print the list of all wh-word types that occur. (wh-words in English are used in questions, relative clauses and exclamations: who, which, what, a

Re: Your Favorite Python Book

2009-05-15 Thread Sam Tregar
Thanks for the suggestions everyone! I've got a copy of Core Python 2nd Edition on the way. -sam -- http://mail.python.org/mailman/listinfo/python-list

Re: How to catch str exception?

2009-05-15 Thread anuraguni...@yahoo.com
> except TypeError,e: >     print "1",e # is caught here > > 1 exceptions must be classes or instances, not str doesn't happen so in 2.5.2 -- http://mail.python.org/mailman/listinfo/python-list

Re: python

2009-05-15 Thread Andre Engels
We may be willing to help you with your homework, but we will not be doing it for you. Please tell us what you have got (whether it be a non-working a program, a partial program or just some ideas about what you might need to do) and what you think is stopping you from getting further. 2009/5/15

Re: How to catch str exception?

2009-05-15 Thread MRAB
anuraguni...@yahoo.com wrote: but the whole point of catching such exception is that i can print its value there are many such exceptions and hence it is not feasible to catch them all or know them all unless i go thru src code. If string exceptions are so difficult to use, don't use them! :-)

Re: How to catch str exception?

2009-05-15 Thread anuraguni...@yahoo.com
> It would be better to write your own exception class: > > class MyException(Exception): >      pass and how would i automatically inject this into 3rd part library -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't run PyQt apps with MacPython

2009-05-15 Thread Morad
On May 13, 7:29 pm, David Boddie wrote: > On Wednesday 13 May 2009 17:53, Morad wrote: > > > I recently got a new MacBook Pro with Leopard, and would like to > > develop using Python and PyQt. I installed the latest Qt SDK, updated > > MacPython to V 2.5.4 and then proceeded to install SIP and PyQ

Re: python

2009-05-15 Thread Mike Driscoll
On May 15, 8:58 am, anica_1...@hotmail.com wrote: > hello, I´m a student of linguistic an I need do this exercises. Can > anybody help me,please? > Thanks > > ◑ Read in some text from a corpus, tokenize it, and print the list of > all wh-word types that occur. (wh-words in English are used in > que

Re: How to catch str exception?

2009-05-15 Thread MRAB
anuraguni...@yahoo.com wrote: It would be better to write your own exception class: class MyException(Exception): pass and how would i automatically inject this into 3rd part library Ah, I wasn't reading carefully enough! :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't run PyQt apps with MacPython

2009-05-15 Thread Morad
On May 15, 10:34 am, Morad wrote: > On May 13, 7:29 pm, David Boddie wrote: > > > > > On Wednesday 13 May 2009 17:53, Morad wrote: > > > > I recently got a new MacBook Pro with Leopard, and would like to > > > develop using Python and PyQt. I installed the latest Qt SDK, updated > > > MacPython t

Re: DOM implementation

2009-05-15 Thread Paul Boddie
On 15 Mai, 15:23, "Emanuele D'Arrigo" wrote: > Hey Paul, > > would you mind continuing this thread on Python + DOM? I'm trying to > implement a DOM Events-like set of classes and I could use another > brain that has some familiarity with the DOM to bounce ideas with. If > you are too busy never mi

Import w/ '.' syntax

2009-05-15 Thread mrstevegross
Remind me: is it possible to craft an import statement like this: import foo.bar If so, what's going on here exactly? Is Python looking for a module called 'bar', in a directory called 'foo', in a search path somewhere? Or am I totally misunderstanding the import semantics. Thanks, --Steve --

Re: Your Favorite Python Book

2009-05-15 Thread Jeff McNeil
On May 11, 5:45 pm, Chris Rebert wrote: > On Mon, May 11, 2009 at 1:44 PM, Sam Tregar wrote: > > Greetings.  I'm working on learning Python and I'm looking for good books to > > read.  I'm almost done with Dive into Python and I liked it a lot. I found > > Programming Python a little dry the last

using urlretrive/urlopen

2009-05-15 Thread Rustom Mody
I am trying to talk to a server that runs on localhost The server runs on http://localhost:7000/ and that opens alright in  a web browser. However if I use urlopen or urlretrieve what I get is this 'file' -- obviously not the one that the browser gets: Query 'http://localhost:7000/' not implemen

Re: Import w/ '.' syntax

2009-05-15 Thread Jeff McNeil
On May 15, 10:50 am, mrstevegross wrote: > Remind me: is it possible to craft an import statement like this: >   import foo.bar > > If so, what's going on here exactly? Is Python looking for a module > called 'bar', in a directory called 'foo', in a search path somewhere? > Or am I totally misunde

Re: Import w/ '.' syntax

2009-05-15 Thread mrstevegross
> In that specific case, you're looking for a module 'bar' in the 'foo' > package, which should be located somewhere on sys.path. > > http://docs.python.org/tutorial/modules.html > > That covers it pretty well. Aha! 'packages'! That makes sense. Thanks, --Steve -- http://mail.python.org/mailman/

Case insensitive version of string.Template?

2009-05-15 Thread python
Using Python 2.6 or higher: Is there a way to configure string.Template() to ignore the case of matched identifiers? In other words, given the following Template string and dictionary where all keys are lowercase, is there a way to have my identifiers expanded based on their lowercase values? impor

Re: Your Favorite Python Book

2009-05-15 Thread Mike Driscoll
On May 11, 4:45 pm, Chris Rebert wrote: > On Mon, May 11, 2009 at 1:44 PM, Sam Tregar wrote: > > Greetings.  I'm working on learning Python and I'm looking for good books to > > read.  I'm almost done with Dive into Python and I liked it a lot. I found > > Programming Python a little dry the last

Re: How to catch str exception?

2009-05-15 Thread Dave Angel
anuraguni...@yahoo.com wrote: except TypeError,e: print "1",e # is caught here 1 exceptions must be classes or instances, not str doesn't happen so in 2.5.2 I tested it in 2.6.2 Perhaps you could try something like: try: raise "xxx" except Exception, e: print "1",e # is

Re: (Windows) Finding out which process has locked a file.

2009-05-15 Thread Tim Golden
CinnamonDonkey wrote: Thanx for the response Tim! :-) Great site! > I'm genuinely surprised to hear you say that... Early morning frustration... I appologise to all... you are totally right. Thank you to all for the responses. Well it's big of you to apologise. In return, I've managed to kno

Re: Your Favorite Python Book

2009-05-15 Thread Lou Pecora
In article , Mike Driscoll wrote: > On May 11, 4:45 pm, Chris Rebert wrote: > > > > I like "Python in a Nutshell" as a reference book, although it's now > > slightly outdated given Python 3.0's release (the book is circa 2.5). > > > > Cheers, > > Chris "Python in a Nutshell" -- Absolutely!

Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread xamalek
How do you parse a string enclosed in Curly Braces? For instance: x = "{ABC EFG IJK LMN OPQ}" I want to do x.split('{} ') and it does not work. Why does it not work and what are EXCEPTIONS to using the split method? That I want to split based on '{', '}' and WHITESPACE. Please advise. Regards

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Chris Rebert
On Fri, May 15, 2009 at 9:12 AM, wrote: > How do you parse a string enclosed in Curly Braces? > > For instance: > > x = "{ABC EFG IJK LMN OPQ}" > > I want to do x.split('{} ') and it does not work. Why does it not work > and what are EXCEPTIONS to using the split method? .split() takes a *substr

Printing a hex character and prefixing it correctly

2009-05-15 Thread xamalek
If I have an integer k, for instance; k = 32 // BASE 10 How do I get print to print it out in HEX and PREFIXED with 0x? What is the PROPER WAY? This does not work: print "This is hex 32: ", int(k, 16) Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Mike Driscoll
On May 15, 11:12 am, xama...@yahoo.com wrote: > How do you parse a string enclosed in Curly Braces? > > For instance: > > x = "{ABC EFG IJK LMN OPQ}" > > I want to do x.split('{} ') and it does not work. Why does it not work > and what are EXCEPTIONS to using the split method? > > That I want to sp

Re: DOM implementation

2009-05-15 Thread Emanuele D'Arrigo
Hi Paul, thank you for your swift reply! On May 15, 3:42 pm, Paul Boddie wrote: > Sure! Just keep your observations coming! I've made a very lazy > attempt at DOM Events support in libxml2dom, I just had a look at libxml2dom, in particular its events.py file. Given that we are working from a sta

Re: Printing a hex character and prefixing it correctly

2009-05-15 Thread Chris Rebert
On Fri, May 15, 2009 at 9:15 AM, wrote: > If I have an integer k, for instance; > > k = 32 // BASE 10 > > How do I get print to print it out in HEX and PREFIXED with 0x? What > is the PROPER WAY? > > This does not work: > >  print "This is hex 32: ", int(k, 16) print "This is hex 32:", hex(k) p

Autosizing column widths in Excel using win32com.client ?

2009-05-15 Thread nonsense
Is there a way to autosize the widths of the excel columns as when you double click them manually? -- http://mail.python.org/mailman/listinfo/python-list

Finding location of an executable in a windows machine?

2009-05-15 Thread nonsense
My python script calls another windows program file. I have the path to that program hardcoded in it. Is there a way for python to automatically find the path to this program? testapp_path = "C:\\Program Files\\testapp\\version\\61\\" Or do i have to do a brute force approach to searching all dri

Re: Sorting a dictionary

2009-05-15 Thread Tobiah
On Tue, 12 May 2009 14:17:54 +0200, Jaime Fernandez del Rio wrote: > This one I think I know... Try with: > > for k in sorted(word_count) : > print k,"=",word_count[k] > > You need to do the sorting before iterating over the keys... Isn't that what's happening here? I read this as the 'sor

Re: Printing a hex character and prefixing it correctly

2009-05-15 Thread BgEddy
xama...@yahoo.com wrote: > If I have an integer k, for instance; > > k = 32 // BASE 10 > > How do I get print to print it out in HEX and PREFIXED with 0x? What > is the PROPER WAY? > > This does not work: > > print "This is hex 32: ", int(k, 16) > > Xav How about this : k=32 print "This i

RE: Printing a hex character and prefixing it correctly

2009-05-15 Thread Andreas Tawn
> If I have an integer k, for instance; > > k = 32 // BASE 10 > > How do I get print to print it out in HEX and PREFIXED with 0x? What > is the PROPER WAY? > > This does not work: > > print "This is hex 32: ", int(k, 16) > > Xav k = 32 print "This is hex 32: ", hex(k) Cheers, Drea -- ht

Re: Sorting a dictionary

2009-05-15 Thread J. Cliff Dyer
On Fri, 2009-05-15 at 09:57 -0700, Tobiah wrote: > On Tue, 12 May 2009 14:17:54 +0200, Jaime Fernandez del Rio wrote: > > > This one I think I know... Try with: > > > > for k in sorted(word_count) : > > print k,"=",word_count[k] > > > > You need to do the sorting before iterating over the ke

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread MRAB
Chris Rebert wrote: On Fri, May 15, 2009 at 9:12 AM, wrote: How do you parse a string enclosed in Curly Braces? For instance: x = "{ABC EFG IJK LMN OPQ}" I want to do x.split('{} ') and it does not work. Why does it not work and what are EXCEPTIONS to using the split method? .split() take

Re: Finding location of an executable in a windows machine?

2009-05-15 Thread MRAB
nonse...@mynonsense.net wrote: My python script calls another windows program file. I have the path to that program hardcoded in it. Is there a way for python to automatically find the path to this program? testapp_path = "C:\\Program Files\\testapp\\version\\61\\" Or do i have to do a brute fo

Re: introspection question: get return type

2009-05-15 Thread Aahz
In article <4a0d2e07$0$9422$426a7...@news.free.fr>, Bruno Desthuilliers wrote: >Aahz a écrit : >> In article <4a0c6e42$0$12031$426a7...@news.free.fr>, >> Bruno Desthuilliers wrote: >>> Marco Mariani a écrit : Bruno Desthuilliers wrote: > Oh, you meant the "return type" ? Nope, no way.

Re: Printing a hex character and prefixing it correctly

2009-05-15 Thread Dave Angel
xama...@yahoo.com wrote: If I have an integer k, for instance; k = 32 // BASE 10 How do I get print to print it out in HEX and PREFIXED with 0x? What is the PROPER WAY? This does not work: print "This is hex 32: ", int(k, 16) Xav How about print "This is hex 32: ", hex(k) (This w

Re: Finding location of an executable in a windows machine?

2009-05-15 Thread Dave Angel
nonse...@mynonsense.net wrote: My python script calls another windows program file. I have the path to that program hardcoded in it. Is there a way for python to automatically find the path to this program? testapp_path = "C:\\Program Files\\testapp\\version\\61\\" Or do i have to do a brute fo

Re: DOM implementation

2009-05-15 Thread Paul Boddie
On 15 Mai, 18:27, "Emanuele D'Arrigo" wrote: > > I just had a look at libxml2dom, in particular its events.py file. > Given that we are working from a standard your implementation is > exceedingly similar to mine and had I know before I started writing my > own classes I would have started from it

Appending traceback from exception in child thread

2009-05-15 Thread Edd
Hi folks, I have a some threadpool code that works like this : tp = ThreadPool(number_of_threads) futures = [tp.future(t) for t in tasks] # each task is callable for f in futures: print f.value() # <-- may propagate an exception The idea being that a Future object represents

Re: Can I get a value's name

2009-05-15 Thread Ken Seehart
jalanb3 wrote: Context for this question arises from some recent code. In particular the "replace_line" method, which takes in a regexp to look for, and a replacement for when it matches. It is supposed to work for single lines only (we add ^ and $ to the regexp), so arguments which have '\n'

ConfigParser and newlines

2009-05-15 Thread Minesh Patel
I am using ConfigParser to parse a config file and I want to maintain the newlines, how is it possible. Example given below. BTW, is there an alternative to configParser, should I use 'exec' instead. Is there any support for yaml built-in or possibly in the future? test.cfg [Foo_Secti

Re: ConfigParser and newlines

2009-05-15 Thread Mike Driscoll
On May 15, 1:09 pm, Minesh Patel wrote: > I am using ConfigParser to parse a config file and I want to maintain > the newlines, how is it possible. Example given below. BTW, is there > an alternative to configParser, should I use 'exec' instead. Is there > any support for yaml built-in or possibly

Re: ConfigParser and newlines

2009-05-15 Thread Tim Chase
test.cfg [Foo_Section] BODY = Line of text 1 Continuing Line of text 1 Executing the code === Python 2.5.1 Stackless 3.1b3 060516 (release25-maint, Mar 6 2009, 14:12:34) [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2 Type "help", "copyright", "credits

Re: Appending traceback from exception in child thread

2009-05-15 Thread Chris Mellon
On Fri, May 15, 2009 at 1:09 PM, Edd wrote: > Hi folks, > > I have a some threadpool code that works like this : > >    tp = ThreadPool(number_of_threads) >    futures = [tp.future(t) for t in tasks] # each task is callable >    for f in futures: >        print f.value() # <-- may propagate an exc

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread kay
On 15 Mai, 18:12, xama...@yahoo.com wrote: > How do you parse a string enclosed in Curly Braces? > > For instance: > > x = "{ABC EFG IJK LMN OPQ}" > > I want to do x.split('{} ') and it does not work. Why does it not work > and what are EXCEPTIONS to using the split method? > > That I want to split

Re: SOAPpy(10060, 'Operation timed out')

2009-05-15 Thread Piet van Oostrum
> "Zhang, Ning" (ZN) wrote: >ZN> Hi all >ZN> I am working for a energy company, we currently want to use api to load >ZN> data into the database. >ZN> I am new for soappy package. I have done a bit research on >ZN> http://www.ibm.com/developerworks/webse ... #resources >ZN>

Re: How to catch str exception?

2009-05-15 Thread Terry Reedy
anuraguni...@yahoo.com wrote: but the whole point of catching such exception is that i can print its value there are many such exceptions and hence it is not feasible to catch them all or know them all unless i go thru src code. I think you have discovered why they are gone in Py3 ;-). -- htt

Tkinter Window On Top

2009-05-15 Thread Trevor
Can a Tkinter application create a COM object and keep its own window on top of it? excel = win32com.client.Dispatch('Excel.Application') I would like the user to be able to see and interact with the Excel application but keep the Tkinter application on top. -- http://mail.python.org/mailman/lis

Re: Finding location of an executable in a windows machine?

2009-05-15 Thread Terry Reedy
nonse...@mynonsense.net wrote: My python script calls another windows program file. I have the path to that program hardcoded in it. Is there a way for python to automatically find the path to this program? testapp_path = "C:\\Program Files\\testapp\\version\\61\\" Or do i have to do a brute fo

Re: Parsing Strings in Enclosed in Curly Braces

2009-05-15 Thread Peter Otten
k...@fiber-space.de wrote: > ttable = string.maketrans("{} ", "\1\1\1") > print x.translate(ttable).split("\1") # -> ['', 'ABC', 'EFG', 'IJK', > 'LMN', 'OPQ', ''] > > The validity of the translation+split depends on the presence of \1 in > the original string of course. Keep one of the split

Re: How to catch str exception?

2009-05-15 Thread Paul Rubin
"anuraguni...@yahoo.com" writes: > there are many such exceptions and hence it is not feasible to catch > them all or know them all unless i go thru src code. But that is true of all exceptions. The alternative seems to be a "checked exception" scheme like Java's, which in practice imposes a hug

Re: How to catch str exception?

2009-05-15 Thread MRAB
Paul Rubin wrote: "anuraguni...@yahoo.com" writes: there are many such exceptions and hence it is not feasible to catch them all or know them all unless i go thru src code. But that is true of all exceptions. The alternative seems to be a "checked exception" scheme like Java's, which in prac

How do i generate a tuple from a generator ?

2009-05-15 Thread eye zak
Hi, I have a situation where i want a tuple from a generator/sequence comprehension. I am wondering, is this possible ? or is this just a bad idea all together? class iterator(object): __slots__ = ('__iters',) def __init__(self,*args): assert len(args) != 0 self.__iters =

Re: How do i generate a tuple from a generator ?

2009-05-15 Thread Emile van Sebille
On 5/15/2009 1:58 PM eye zak said... Hi, I have a situation where i want a tuple from a generator/sequence comprehension. I am wondering, is this possible ? or is this just a bad idea all together? class iterator(object): __slots__ = ('__iters',) def __init__(self,*args): asser

Re: Just wondering

2009-05-15 Thread norseman
Gediminas Kregzde wrote: Hello, I'm Vilnius college II degree student and last semester our teacher introduced us to python I've used to program with Delphi, so I very fast adopted to python Now I'm developing cross platform program and use huge amounts of data. Program is needed to run as fast

Re: Just wondering

2009-05-15 Thread norseman
Marco Mariani wrote: Gediminas Kregzde wrote: def doit(i): pass def main(): a = [0] * 1000 t = time() map(doit, a) print "map time: " + str(time() - t) Here you are calling a function ten million times, build a list with of ten million None results, then throw it away.

Re: ConfigParser and newlines

2009-05-15 Thread Minesh Patel
> Not as best I can tell.  From my /usr/lib/python2.5/ConfigParser.py file, > around line 441: > >  if line[0].isspace() and cursect is not None and optname: >    value = line.strip() >    if value: >      cursect[optname] = "%s\n%s" % (cursect[optname], value) > > That "value = line.strip()" is wh

ConfigParser examples?

2009-05-15 Thread Esmail
Hi all, Can anyone point to on the web, or possibly share a simple example of the use of the ConfigParser module? I have a program that has a lot of flags in various places (yes, ugly I know), so I am trying to consolidate this information in a configuration file so that the program can pull the

  1   2   >