PyOhio CFP due May 15 (tomorrow)

2009-05-15 Thread Catherine Devlin
A reminder: PyOhio's call for proposals is due May 15 - tomorrow! PyOhio 2009, the second annual Python programming mini-conference for Ohio and surrounding areas, will take place Saturday-Sunday, July 25-26, 2009 at the Ohio State University in Columbus, Ohio. A variety of activities are

Python-URL! - weekly Python news and links (May 14)

2009-05-15 Thread Gabriel Genellina
QOTW: Tail recursion *unifies* message passing and function calling. *This* is the reason tail recursion is cool. - JRM http://funcall.blogspot.com/2009/05/you-knew-id-say-something-part-iii.html First beta of Python 3.1 released

Re: [ANN] Introduction to Python course, San Francisco, Jun 2009

2009-05-15 Thread wesley chun
* FINAL REMINDER * we have about 10-15 spaces remaining for our June course coming up in about a month. if you have coworkers or colleagues that need to learn Python, the weather is great up here in northern california in the city by the bay. there are discounts for students and teachers, as

Re: putting date strings in order

2009-05-15 Thread Peter Otten
noydb wrote: On May 14, 4:13 pm, Scott David Daniels scott.dani...@acm.org wrote: Peter Otten wrote: Hm, if ordered_raster_list is guaranteed to contain one string item for every month the above can be simplified to months = [ 'precip_jan', 'precip_feb', 'precip_mar', 'precip_apr',

creating python code with dynamic file name

2009-05-15 Thread bijoy franco
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 -- http://mail.python.org/mailman/listinfo/python-list

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:

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

2009-05-15 Thread alex23
On May 14, 5:49 am, Gunter Henriksen gunterhenrik...@gmail.com 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

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

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 mailman.183.1242371089.8015.python-l...@python.org, 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 mailman.183.1242371089.8015.python-l...@python.org, 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

[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

Re: File System Redirection Windows x 64 box.

2009-05-15 Thread Rohit Srivastava
On May 15, 12:05 pm, Rohit Srivastava er.srivastavaro...@gmail.com 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

Re: How to catch str exception?

2009-05-15 Thread Kurt Symanzik
anuraguni...@yahoo.com 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

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 bdesth.quelquech...@free.quelquepart.fr 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.

Re: urllib2 slow for multiple requests

2009-05-15 Thread Tomas Svarovsky
On May 14, 6:33 pm, Richard Brodie r.bro...@rl.ac.uk wrote: Tomas Svarovsky svarovsky.to...@gmail.com 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

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

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

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 mailman.185.1242375959.8015.python-l...@python.org, Igor Katson wrote: Lawrence D'Oliveiro wrote: In message mailman.183.1242371089.8015.python-l...@python.org, Igor Katson wrote: I have problems in getting a SocketServer to shutdown. Do you want to do a shutdown or a

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 mailman.185.1242375959.8015.python-l...@python.org, Igor Katson wrote: Lawrence D'Oliveiro wrote: In message mailman.183.1242371089.8015.python-l...@python.org, Igor Katson wrote: I have problems in getting a SocketServer to shutdown.

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

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

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

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 ccur...@gmail.com 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

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 gediminas.kreg...@gmail.com wrote: Hello, I'm Vilnius college II degree student and last

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

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

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(...)

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

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

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

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

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 how

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

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 particular

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,

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 da...@boddie.org.uk 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

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

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 mora...@gmail.com wrote: On May 13, 7:29 pm, David Boddie da...@boddie.org.uk 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,

Re: DOM implementation

2009-05-15 Thread Paul Boddie
On 15 Mai, 15:23, Emanuele D'Arrigo man...@gmail.com 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

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 c...@rebertia.com wrote: On Mon, May 11, 2009 at 1:44 PM, Sam Tregar s...@tregar.com 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

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: htmlbody bgcolor=#ff Query

Re: Import w/ '.' syntax

2009-05-15 Thread Jeff McNeil
On May 15, 10:50 am, mrstevegross mrstevegr...@gmail.com 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

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

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?

Re: Your Favorite Python Book

2009-05-15 Thread Mike Driscoll
On May 11, 4:45 pm, Chris Rebert c...@rebertia.com wrote: On Mon, May 11, 2009 at 1:44 PM, Sam Tregar s...@tregar.com 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

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

Re: Your Favorite Python Book

2009-05-15 Thread Lou Pecora
In article e1db4ac7-4997-401b-9a1f-112787a9e...@r3g2000vbp.googlegroups.com, Mike Driscoll kyoso...@gmail.com wrote: On May 11, 4:45 pm, Chris Rebert c...@rebertia.com wrote: I like Python in a Nutshell as a reference book, although it's now slightly outdated given Python 3.0's release

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, 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? .split() takes a

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

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 p...@boddie.org.uk 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

Re: Printing a hex character and prefixing it correctly

2009-05-15 Thread Chris Rebert
On Fri, May 15, 2009 at 9:15 AM, 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) print This is hex 32:,

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

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

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 is hex 32:

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

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 keys... Isn't

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

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

Re: introspection question: get return type

2009-05-15 Thread Aahz
In article 4a0d2e07$0$9422$426a7...@news.free.fr, Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid wrote: Aahz a écrit : In article 4a0c6e42$0$12031$426a7...@news.free.fr, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr wrote: Marco Mariani a écrit : Bruno

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

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

Re: DOM implementation

2009-05-15 Thread Paul Boddie
On 15 Mai, 18:27, Emanuele D'Arrigo man...@gmail.com 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

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

Re: ConfigParser and newlines

2009-05-15 Thread Mike Driscoll
On May 15, 1:09 pm, Minesh Patel min...@gmail.com 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

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 or

Re: Appending traceback from exception in child thread

2009-05-15 Thread Chris Mellon
On Fri, May 15, 2009 at 1:09 PM, Edd e...@nunswithguns.net 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

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

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

2009-05-15 Thread Piet van Oostrum
Zhang, Ning ning.zh...@centrica.com (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 ;-). --

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

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

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 splitting

Re: How to catch str exception?

2009-05-15 Thread Paul Rubin
anuraguni...@yahoo.com 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

Re: How to catch str exception?

2009-05-15 Thread MRAB
Paul Rubin wrote: anuraguni...@yahoo.com 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

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

  1   2   3   >