Re: Where's a DOM builder that uses the Builder Pattern to ... build DOMs?

2010-01-05 Thread Stefan Behnel
Phlip, 04.01.2010 21:01: Not Hyp: I hope I'm wrong, but seems that DOMBuilder, found among the various xml.dom packages, cannot build DOM like this: var html = DomBuilder.apply(); var form = html.FORM( html.DIV( html.INPUT({type : 'text', name : 'email'}), html.INPUT({type : 'text

Re: [Python] Printing plain text with exact positioning on Windows

2010-01-05 Thread Chris Gonnerman
KvS wrote: So now I'm looking for other ways to get this printing job done. I know of Tim Goldens page about Windows printing: http://timgolden.me.uk/python/win32_how_do_i/print.html and have been googling a lot, but I'm still not convinced what the best way to go is. E.g. I can't get clear wheth

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Steven D'Aprano
On Tue, 05 Jan 2010 02:31:34 +, r0g wrote: > A pattern I have used a few times is that of returning an explicit > success/failure code alongside whatever the function normally returns. That doesn't work for languages that can only return a single result, e.g. C or Pascal. You can fake it by

A null program - what is it doing?

2010-01-05 Thread Gib Bogle
No doubt a dumb question from a noob: The following program (a cut down version of some test code) uses no CPU, and does not terminate: import sys from PyQt4.QtCore import * if __name__=="__main__": app = QCoreApplication(sys.argv) sys.exit(app.exec_()) What is the program doing? Wh

Re: python xmlrpc client with ssl client certificates and standard modules

2010-01-05 Thread News123
Hi Martin, Thanks a lot for your reply. It helped me to find the correct solution. Unfortunaltely xmlrpclib.ServerProxy does not allow a host tuple, but just a uri. So the simplest solution, that I found is to create a custom transport import xmlrpclib class SafeTransportWithCert(xmlrpclib.Sa

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Lie Ryan wrote: > On 1/5/2010 1:31 PM, r0g wrote: >> Michi wrote: >>> On Jan 4, 1:30 pm, Steven D'Aprano >>> wrote: >> A pattern I have used a few times is that of returning an explicit >> success/failure code alongside whatever the function normally returns. >> While subsequent programmers migh

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Chris Rebert
On Tue, Jan 5, 2010 at 1:07 AM, r0g wrote: > Lie Ryan wrote: >> I have been looking at Haskell recently and the way the pure functional >> language handled exceptions and I/O gives me a new distinct "insight" >> that exceptions can be thought of as a special return value that is >> implicitly wra

lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-05 Thread VYAS ASHISH M-NTB837
Dear All I have Python 3.1 installed on Windows XP and Works nice. I downloaded lxml 2.2.4 (lxml-2.2.4.win32-py3.1.exe) from pypi. When I try: from lxml import etree I get: ImportError: DLL load failed: This application has failed to start because the application configuration is incorrect. R

Re: Efficiently determine where documents differ

2010-01-05 Thread Richard
On Jan 5, 9:46 am, "Gabriel Genellina" wrote: > En Mon, 04 Jan 2010 19:04:12 -0300, Richard escribió: > > > I have been using the difflib library to find where 2 large HTML > > documents differ. The Differ().compare() method does this, but it is > > very slow - atleast 100x slower than the unix d

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Steven D'Aprano wrote: > On Tue, 05 Jan 2010 02:31:34 +, r0g wrote: > >> A pattern I have used a few times is that of returning an explicit >> success/failure code alongside whatever the function normally returns. > > That doesn't work for languages that can only return a single result, > e.

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Paul Rudin
r0g writes: > Steven D'Aprano wrote: >> On Tue, 05 Jan 2010 02:31:34 +, r0g wrote: >> >>> A pattern I have used a few times is that of returning an explicit >>> success/failure code alongside whatever the function normally returns. >> >> That doesn't work for languages that can only return

Re: A null program - what is it doing?

2010-01-05 Thread r0g
Gib Bogle wrote: > No doubt a dumb question from a noob: > > The following program (a cut down version of some test code) uses no > CPU, and does not terminate: > > import sys > from PyQt4.QtCore import * > > if __name__=="__main__": > app = QCoreApplication(sys.argv) > sys.exit(app.exec

Re: A null program - what is it doing?

2010-01-05 Thread Almar Klein
2010/1/5 r0g > Gib Bogle wrote: > > No doubt a dumb question from a noob: > > > > The following program (a cut down version of some test code) uses no > > CPU, and does not terminate: > > > > import sys > > from PyQt4.QtCore import * > > > > if __name__=="__main__": > > app = QCoreApplication

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Chris Rebert wrote: > > On Tue, Jan 5, 2010 at 1:07 AM, r0g wrote: >> Lie Ryan wrote: >>> I have been looking at Haskell recently and the way the pure functional >>> language handled exceptions and I/O gives me a new distinct "insight" >>> that exceptions can be thought of as a special return val

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Paul Rudin wrote: > r0g writes: > >> Steven D'Aprano wrote: >>> On Tue, 05 Jan 2010 02:31:34 +, r0g wrote: >>> A pattern I have used a few times is that of returning an explicit success/failure code alongside whatever the function normally returns. >>> That doesn't work for language

ctypes: How to call unexported functions in a dll

2010-01-05 Thread Coert Klaver (DT)
Hi, I am using ctypes in python 3 on a WXP machine Loading a dll and using its exported functions works fine. Now I want to use a function in the dll that is not exported. In C this can be done by just casting the address in the dll of that function to an apropriate function pointer and call it

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Dave Angel
r0g wrote: Maybe, although I recently learned on here that one can't rely on assert statements in production code, their intended use is to aid debugging and testing really. Hopefully, what you learned is that you can't use assert() in production code to validate user data. It's fine t

Re: A null program - what is it doing?

2010-01-05 Thread Dave Angel
r0g wrote: Gib Bogle wrote: No doubt a dumb question from a noob: The following program (a cut down version of some test code) uses no CPU, and does not terminate: import sys from PyQt4.QtCore import * if __name__=="__main__": app = QCoreApplication(sys.argv) sys.exit(app.exec_())

embedded python on mac - linking problem

2010-01-05 Thread Krzysztof Kobus
Hi, I have a problem with linking python module with my application on mac in order to make the module available in "embedded python". My python module is contained in j3kmodule.cxx file and module initialization function is exported in j3kmodule.h j3kmodule.h: PyMODINIT_FUNC PyI

Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread KvS
On Jan 5, 9:21 am, "alejandro" wrote: > Did you mean borderless printing? > Every printer needs his margins, some more some less. Some printers have the > ability to do borderless printing but usualy they can do it only on special > or photo paper. So you can adjust the pdf as you wish, even with

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Ben Finney
r0g writes: > Paul Rudin wrote: > > Doesn't python just return a single result? (I know it can be a > > tuple and assignment statements will unpack a tuple for you.) > > Yes, it returns a tuple if you return more than one value, it just has > a lovely syntax for it. No, there is nothing inherent

Re: [Python] Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread Chris Gonnerman
KvS wrote: ... can I adjust the options normally appearing in the Printing Dialog through Python? Yes, if you use my method or my module, as I gave in my previous post. If you use Adobe Reader to print, I'm not sure how to automate the print settings. -- http://mail.python.org/mailman/list

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Dave Angel wrote: > > > r0g wrote: >> >> >> Maybe, although I recently learned on here that one can't rely on assert >> statements in production code, their intended use is to aid debugging >> and testing really. >> >> > Hopefully, what you learned is that you can't use assert() in productio

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Roy Smith
In article , r0g wrote: > No, but that's why I try not to use languages where you can only return > a single result, I always found that an arbitrary and annoying > constraint to have. I leads to ugly practices like "magic" return values > in C or explicitly packing things into hashtables like

Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread alejandro
Did you mean borderless printing? Every printer needs his margins, some more some less. Some printers have the ability to do borderless printing but usualy they can do it only on special or photo paper. So you can adjust the pdf as you wish, even with no margins, and then try to find under prin

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Steven D'Aprano
On Tue, 05 Jan 2010 13:06:20 +, r0g wrote: > Dave Angel wrote: >> >> >> r0g wrote: >>> >>> >>> Maybe, although I recently learned on here that one can't rely on >>> assert >>> statements in production code, their intended use is to aid debugging >>> and testing really. >>> >>> >> Hopefully

Talking with ebay using easyBay

2010-01-05 Thread starglider develop
Hi, I made an application to manage auctions with easyBay my problem is that easybay site is down and there is any other source of information in the net regarding the packadge. Any one has the docs? or know how to make a search? Thank you in advance. -

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread D'Arcy J.M. Cain
On 05 Jan 2010 14:02:50 GMT Steven D'Aprano wrote: > shouldn't use assert for validating user data except for quick-and-dirty > scripts you intend to use once and throw away. A mythcial beast that has yet to be spotted in the wild. -- D'Arcy J.M. Cain | Democracy is three wolves http

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Ben Finney wrote: > r0g writes: > >> Paul Rudin wrote: >>> Doesn't python just return a single result? (I know it can be a >>> tuple and assignment statements will unpack a tuple for you.) >> Yes, it returns a tuple if you return more than one value, it just has >> a lovely syntax for it. > > No

Re: twenty years ago Guido created Python

2010-01-05 Thread n00m
Stick your English into your ass -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Steven D'Aprano wrote: > On Tue, 05 Jan 2010 13:06:20 +, r0g wrote: >> Well maybe I didn't quite get it then, could you explain a bit further? >> >> My understanding was that asserts aren't executed at all if python is >> started with the -O or -OO option, > > Correct. > > >> or run throug

Re: ctypes: How to call unexported functions in a dll

2010-01-05 Thread Thomas Heller
Am 05.01.2010 12:19, schrieb Coert Klaver (DT): > Hi, > > I am using ctypes in python 3 on a WXP machine > > Loading a dll and using its exported functions works fine. > > Now I want to use a function in the dll that is not exported. > > In C this can be done by just casting the address in the

Re: Dynamic text color

2010-01-05 Thread Dave McCormick
John Posner wrote: On Fri, 01 Jan 2010 21:01:04 -0500, Cousin Stanley wrote: I was not familiar with the re.finditer method for searching strings ... Stanley and Dave -- So far, we've just been using finditer() to perform standard-string searches (e.g. on the word "red"). Sinc

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Dave Angel
r0g wrote: Dave Angel wrote: r0g wrote: Maybe, although I recently learned on here that one can't rely on assert statements in production code, their intended use is to aid debugging and testing really. Hopefully, what you learned is that you can't use assert() in product

Re: embedded python on mac - linking problem

2010-01-05 Thread Benjamin Kaplan
On Tue, Jan 5, 2010 at 7:33 AM, Krzysztof Kobus wrote: > Hi, > > I have a problem with linking python module with my application on mac in > order to make the module available in "embedded python". > > My python module is contained in  j3kmodule.cxx file and module > initialization function is e

Re: Speeding up network access: threading?

2010-01-05 Thread Jens Müller
Hello, The fairly obvious thing to do is use a queue.queue for tasks and another for results and a pool of threads that read, fetch, and write. Thanks, indeed. Is a list thrad-safe or do I need to lock when adding the results of my worker threads to a list? The order of the elements in the li

Re: Speeding up network access: threading?

2010-01-05 Thread Jens Müller
Hello, The fairly obvious thing to do is use a queue.queue for tasks and another for results and a pool of threads that read, fetch, and write. Thanks, indeed. Is a list thrad-safe or do I need to lock when adding the results of my worker threads to a list? The order of the elements in the l

Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread KvS
On Jan 5, 12:56 pm, Chris Gonnerman wrote: > KvS wrote: > > ... can I adjust the options normally appearing in > > the Printing Dialog through Python? > > Yes, if you use my method or my module, as I gave in my previous post.   > If you use Adobe Reader to print, I'm not sure how to automate the p

Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread KvS
On Jan 5, 12:56 pm, Chris Gonnerman wrote: > KvS wrote: > > ... can I adjust the options normally appearing in > > the Printing Dialog through Python? > > Yes, if you use my method or my module, as I gave in my previous post.   > If you use Adobe Reader to print, I'm not sure how to automate the p

Re: A null program - what is it doing?

2010-01-05 Thread John Posner
No doubt a dumb question from a noob: The following program (a cut down version of some test code) uses no CPU, and does not terminate: import sys from PyQt4.QtCore import * if __name__=="__main__": app = QCoreApplication(sys.argv) sys.exit(app.exec_()) What is the program doing?

Re: Where's a DOM builder that uses the Builder Pattern to ... build DOMs?

2010-01-05 Thread Phlip
On Jan 5, 12:16 am, Stefan Behnel wrote: > Note that there are tons of ways to generate HTML with Python. Forgot to note - I'm generating schematic XML, and I'm trying to find a way better than the Django template I started with! -- http://mail.python.org/mailman/listinfo/python-list

Re: Speeding up network access: threading?

2010-01-05 Thread MRAB
Jens Müller wrote: Hello, The fairly obvious thing to do is use a queue.queue for tasks and another for results and a pool of threads that read, fetch, and write. Thanks, indeed. Is a list thrad-safe or do I need to lock when adding the results of my worker threads to a list? The order of th

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Lie Ryan
On 1/6/2010 1:48 AM, r0g wrote: Steven D'Aprano wrote: On Tue, 05 Jan 2010 13:06:20 +, r0g wrote: If that's the case how can you expect it to validate anything at all in production? The asserts still operate so long as you don't use the -O switch. Do you mean for debugging in situ or so

Re: Speeding up network access: threading?

2010-01-05 Thread Antoine Pitrou
Le Tue, 05 Jan 2010 15:04:56 +0100, Jens Müller a écrit : > > Is a list thrad-safe or do I need to lock when adding the results of my > worker threads to a list? The order of the elements in the list does not > matter. The built-in list type is thread-safe, but is doesn't provide the waiting fea

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Steve Holden
D'Arcy J.M. Cain wrote: > On 05 Jan 2010 14:02:50 GMT > Steven D'Aprano wrote: >> shouldn't use assert for validating user data except for quick-and-dirty >> scripts you intend to use once and throw away. > > A mythcial beast that has yet to be spotted in the wild. > Not true (he wrote, picking

Re: Dynamic text color

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 10:31:09 -0500, Dave McCormick wrote: ... But this is what I have so far. ## file = 'red.txt' file = open("red.txt","r") rList = file.readlines() file.close() redList = str(rList).split() Dave, you're doing exactly the right thing: gradually expanding your

parsing an Excel formula with the re module

2010-01-05 Thread vsoler
Hello, I am acessing an Excel file by means of Win 32 COM technology. For a given cell, I am able to read its formula. I want to make a map of how cells reference one another, how different sheets reference one another, how workbooks reference one another, etc. Hence, I need to parse Excel formul

Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread KvS
On Jan 5, 12:56 pm, Chris Gonnerman wrote: > KvS wrote: > > ... can I adjust the options normally appearing in > > the Printing Dialog through Python? > > Yes, if you use my method or my module, as I gave in my previous post.   > If you use Adobe Reader to print, I'm not sure how to automate the p

it gets worse (was: How do you configure IDLE on a Mac...)

2010-01-05 Thread Mensanator
On Jan 5, 12:32 am, Ned Deily wrote: > In article > <0d70cb54-3d77-4176-b621-e764ecf61...@26g2000yqo.googlegroups.com>, > > > > > >  Mensanator wrote: > > I assume I've been using the IDLE from macports. From the command > > prompt I've > > been typing "idle". This launches a "shell" window which

Re: parsing an Excel formula with the re module

2010-01-05 Thread MRAB
vsoler wrote: Hello, I am acessing an Excel file by means of Win 32 COM technology. For a given cell, I am able to read its formula. I want to make a map of how cells reference one another, how different sheets reference one another, how workbooks reference one another, etc. Hence, I need to pa

Re: Speeding up network access: threading?

2010-01-05 Thread Jens Müller
Hi and sorry for double posting - had mailer problems, Terry said "queue". not "list". Use the Queue class (it's thread-safe) in the "Queue" module (assuming you're using Python 2.x; in Python 3.x it's called the "queue" module). Yes yes, I know. I use a queue to realize the thread pool queue,

Re: IOError - cannot create file (linux daemon-invoked script)

2010-01-05 Thread Nobody
On Mon, 04 Jan 2010 21:30:31 -0800, cassiope wrote: > One more tidbit observed: my last note, that it works when using > seteuid/setegid? > Well - that only applies if the daemon is running under strace (!). > It fails > if started directly by root, or if the strace session has ended, > leaving th

Re: twenty years ago Guido created Python

2010-01-05 Thread Phlip
On Dec 31 2009, 2:06 pm, Steve Howell wrote: > Python is a truly awesome programming language.  Not only is Guido a > genius language designer, but he is also a great project leader.  What > an accomplishment.  Congratulations to everybody who has contributed > to Python in the last two decades!

Re: parsing an Excel formula with the re module

2010-01-05 Thread vsoler
On 5 ene, 19:35, MRAB wrote: > vsoler wrote: > > Hello, > > > I am acessing an Excel file by means of Win 32 COM technology. > > For a given cell, I am able to read its formula. I want to make a map > > of how cells reference one another, how different sheets reference one > > another, how workboo

Re: parsing an Excel formula with the re module

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 13:12:00 -0500, vsoler wrote: Hello, I am acessing an Excel file by means of Win 32 COM technology. For a given cell, I am able to read its formula. I want to make a map of how cells reference one another, how different sheets reference one another, how workbooks reference

Re: parsing an Excel formula with the re module

2010-01-05 Thread Mensanator
On Jan 5, 12:35 pm, MRAB wrote: > vsoler wrote: > > Hello, > > > I am acessing an Excel file by means of Win 32 COM technology. > > For a given cell, I am able to read its formula. I want to make a map > > of how cells reference one another, how different sheets reference one > > another, how work

Re: fsync() doesn't work as advertised?

2010-01-05 Thread Nobody
On Mon, 04 Jan 2010 08:09:56 -0800, Brian D wrote: > If I'm running a process in a loop that runs for a long time, I > occasionally would like to look at a log to see how it's going. > > I know about the logging module, and may yet decide to use that. > > Still, I'm troubled by how fsync() doesn

Re: What is the best data structure for a very simple spreadsheet?

2010-01-05 Thread vsoler
On 3 ene, 22:40, mdipierro wrote: > Perhaps this can be useful:http://www.web2py.com/examples/spreadsheet > > The code is in a single file with not dependencies and it does not > require web2py to > run:http://code.google.com/p/web2py/source/browse/gluon/contrib/spreadshe... > > Here is a sample

Re: Speeding up network access: threading?

2010-01-05 Thread Steve Holden
Jens Müller wrote: > Hi and sorry for double posting - had mailer problems, > >> Terry said "queue". not "list". Use the Queue class (it's thread-safe) >> in the "Queue" module (assuming you're using Python 2.x; in Python 3.x >> it's called the "queue" module). > > Yes yes, I know. I use a queue

Re: Printing plain text with exact positioning on Windows

2010-01-05 Thread Nobody
On Tue, 05 Jan 2010 04:40:14 -0800, KvS wrote: >> Did you mean borderless printing? >> Every printer needs his margins, some more some less. Some printers have the >> ability to do borderless printing but usualy they can do it only on special >> or photo paper. So you can adjust the pdf as you wis

Re: parsing an Excel formula with the re module

2010-01-05 Thread MRAB
vsoler wrote: On 5 ene, 19:35, MRAB wrote: vsoler wrote: Hello, I am acessing an Excel file by means of Win 32 COM technology. For a given cell, I am able to read its formula. I want to make a map of how cells reference one another, how different sheets reference one another, how workbooks ref

Re: twenty years ago Guido created Python

2010-01-05 Thread Steve Holden
Phlip wrote: > On Dec 31 2009, 2:06 pm, Steve Howell wrote: > >> Python is a truly awesome programming language. Not only is Guido a >> genius language designer, but he is also a great project leader. What >> an accomplishment. Congratulations to everybody who has contributed >> to Python in t

Re: parsing an Excel formula with the re module

2010-01-05 Thread vsoler
On 5 ene, 20:05, Mensanator wrote: > On Jan 5, 12:35 pm, MRAB wrote: > > > > > vsoler wrote: > > > Hello, > > > > I am acessing an Excel file by means of Win 32 COM technology. > > > For a given cell, I am able to read its formula. I want to make a map > > > of how cells reference one another, ho

Fwd: I would like to install Python on my 64 bit Win 7

2010-01-05 Thread aung paing Soe
-- Forwarded message -- From: aung paing Soe Date: Tue, Jan 5, 2010 at 11:27 AM Subject: I would like to install Python on my 64 bit Win 7 To: webmas...@python.org Hello , I would like to study about Python Programming . So I want to install Python . But my laptop is Wi

Re: parsing an Excel formula with the re module

2010-01-05 Thread Tim Chase
vsoler wrote: Hence, I need to parse Excel formulas. Can I do it by means only of re (regular expressions)? I know that for simple formulas such as "=3*A7+5" it is indeed possible. What about complex for formulas that include functions, sheet names and possibly other *.xls files? Where things

Re: parsing an Excel formula with the re module

2010-01-05 Thread vsoler
On 5 ene, 20:21, vsoler wrote: > On 5 ene, 20:05, Mensanator wrote: > > > > > On Jan 5, 12:35 pm, MRAB wrote: > > > > vsoler wrote: > > > > Hello, > > > > > I am acessing an Excel file by means of Win 32 COM technology. > > > > For a given cell, I am able to read its formula. I want to make a ma

please help shrink this each_with_index() implementation

2010-01-05 Thread Phlip
Hypo Nt: def each_with_index(seq): index = 0 result = [] for item in seq: result.append([item, index]) index += 1 return result My Pythonic sequencing skills are obviously feeble. Can anything think of a way to write that in fewer lines? -- Phlip http://c2.com/c

Re: Fwd: I would like to install Python on my 64 bit Win 7

2010-01-05 Thread Dave McCormick
aung paing Soe wrote: -- Forwarded message -- From: aung paing Soe Date: Tue, Jan 5, 2010 at 11:27 AM Subject: I would like to install Python on my 64 bit Win 7 To: webmas...@python.org Hello ,   I would like to study about Python Pr

Re: Dynamic text color

2010-01-05 Thread Dave McCormick
John Posner wrote: Dave, you're doing exactly the right thing: gradually expanding your program, to provide more functionality and to learn more about the available programming tools. It's also very good that you take care to close() the file after processing it. Now for the bad news ... S

Re: twenty years ago Guido created Python

2010-01-05 Thread Mensanator
On Jan 5, 8:22 am, n00m wrote: > Stick your English into your ass Most people would say "up your ass". And use a period at the end of the sentence. Got any more funny insults? -- http://mail.python.org/mailman/listinfo/python-list

Re: Fwd: I would like to install Python on my 64 bit Win 7

2010-01-05 Thread Benjamin Kaplan
On Tue, Jan 5, 2010 at 3:03 PM, Dave McCormick wrote: > > > aung paing Soe wrote: > > -- Forwarded message -- > From: aung paing Soe > Date: Tue, Jan 5, 2010 at 11:27 AM > Subject: I would like to install Python on my 64 bit Win 7 > To: webmas...@python.org > > > Hello , >    

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread akean
On Jan 6, 8:58 am, Phlip wrote: > Hypo Nt: > > def each_with_index(seq): >     index = 0 >     result = [] > >     for item in seq: >       result.append([item, index]) >       index += 1 > >     return result > > My Pythonic sequencing skills are obviously feeble. Can anything think > of a way to

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Carsten Haese
Phlip wrote: > Hypo Nt: > > def each_with_index(seq): > index = 0 > result = [] > > for item in seq: > result.append([item, index]) > index += 1 > > return result > > My Pythonic sequencing skills are obviously feeble. Can anything think > of a way to write that in f

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Marco Nawijn
On Jan 5, 8:58 pm, Phlip wrote: > Hypo Nt: > > def each_with_index(seq): >     index = 0 >     result = [] > >     for item in seq: >       result.append([item, index]) >       index += 1 > >     return result > > My Pythonic sequencing skills are obviously feeble. Can anything think > of a way to

Re: Dynamic text color

2010-01-05 Thread John Posner
On Tue, 05 Jan 2010 15:08:04 -0500, Dave McCormick wrote: It's certainly a mistake to use the expression "str(rList).split()". Using str() to convert the list "rList" into a string creates a mess that includes square-bracket characters. Did this actually work for you? It sort of worked

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Phlip
> > My Pythonic sequencing skills are obviously feeble. Can anything think > > of a way to write that in fewer lines? Thanks, all! > Couldn't you just use the built-in enumerate() to replace the whole thing? Because that would involve, like, reading an entire Python book just to locate that meth

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Antoine Pitrou
>> Couldn't you just use the built-in enumerate() to replace the whole >> thing? > > Because that would involve, like, reading an entire Python book just to > locate that method? Actually, no. It just involves reading one of the most important pages in the documentation, the page which describ

Re: A null program - what is it doing?

2010-01-05 Thread Gib Bogle
r0g wrote: Gib Bogle wrote: No doubt a dumb question from a noob: The following program (a cut down version of some test code) uses no CPU, and does not terminate: import sys from PyQt4.QtCore import * if __name__=="__main__": app = QCoreApplication(sys.argv) sys.exit(app.exec_()) Wh

Commands for a breakpoint in .pdbrc

2010-01-05 Thread Pablo Torres N.
Hi all, I'd like to save the commands for a breakpoint in a .pdbrc, something like: b 81 commands 1 pp foo.attr1 pp foo.attr2 end b 108 commands 2 pp bar.attr1 pp bar.attr2 end This would automate setting the environment for the debugging session. However, this does not work with 'python -m pdb

Re: Dynamic text color

2010-01-05 Thread Dave McCormick
John Posner wrote: On Tue, 05 Jan 2010 15:08:04 -0500, Dave McCormick wrote: It sounds like the program is doing exactly what you TOLD it to do (which might not be what you WANT it to do): 1. In an earlier pass on the text, color the string "dog" red. 2. In a later pass, color the strin

Python multiprocessing: Permission denied

2010-01-05 Thread t0ster
Hi guys, I'm getting an error when trying to execute python program that uses multiprocessing package: File "/usr/local/lib/python2.6/multiprocessing/__init__.py", line 178, in RLock return RLock() File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 142, in __init__ Se

Re: it gets worse (was: How do you configure IDLE on a Mac...)

2010-01-05 Thread Ned Deily
In article <6672dad2-26ba-458b-8075-21bac6506...@e37g2000yqn.googlegroups.com>, Mensanator wrote: [...] > So, for all practical purposes, the macports install is broken also. > > IDLE simply does not work in an X11 window (you think someone would > have noticed that). The missing preferences is

Re: parsing an Excel formula with the re module

2010-01-05 Thread MRAB
Mensanator wrote: On Jan 5, 12:35 pm, MRAB wrote: vsoler wrote: Hello, I am acessing an Excel file by means of Win 32 COM technology. For a given cell, I am able to read its formula. I want to make a map of how cells reference one another, how different sheets reference one another, how workbo

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Ben Finney
r0g writes: > Of course I'm now guilty of pedantry too :/ I might have let it slip > had you not started your reply with the word "No", that just p* me > off. Well, if being told “no” is going to piss you off, I think you're in for a rough time. > Having said that I find the mental image of

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Phlip
On Jan 5, 1:10 pm, Antoine Pitrou wrote: > http://docs.python.org/library/functions.html > > Don't forget that the Python documentation is rich and structured. > And good luck. Does it say how to convert a string containing either an integer representation, or something alphabetic, into an integ

Re: Python multiprocessing: Permission denied

2010-01-05 Thread Steven D'Aprano
On Tue, 05 Jan 2010 13:52:18 -0800, t0ster wrote: > It looks like the user don't have permission to access shared memory. > When executing with root privileges it works fine. > > Is there any solution to run it as normal user(not root)? Then give the user permission to access shared memory. Why

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Steven D'Aprano
On Wed, 06 Jan 2010 09:39:08 +1100, Ben Finney wrote: > r0g writes: > >> Of course I'm now guilty of pedantry too :/ I might have let it slip >> had you not started your reply with the word "No", that just p* me >> off. > > Well, if being told “no” is going to piss you off, I think you're i

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Steven D'Aprano
On Tue, 05 Jan 2010 14:40:49 -0800, Phlip wrote: > On Jan 5, 1:10 pm, Antoine Pitrou wrote: > >> http://docs.python.org/library/functions.html >> >> Don't forget that the Python documentation is rich and structured. And >> good luck. > > Does it say how to convert a string containing either an

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Phlip
> > Does it say how to convert a string containing either an integer > > representation, or something alphabetic, into an integer, or a zero, in > > like 1 method call? (No except: ?) > > If you mean something like this: > > >>> int('153') > > 153 The point: int('') or int('something') both throw

subprocess.Popen does not close pipe in an error case

2010-01-05 Thread Steven K. Wong
Below, I have a Python script that launches 2 child programs, prog1 and prog2, with prog1's stdout connected to prog2's stdin via a pipe. (It's like executing "prog1 | prog2" in the shell.) If both child programs exit with 0, then the script runs to completion. But if prog2 exits with non-0, prog1

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Phlip
Peng Yu wrote: > Otherwise, could some python expert explain to me why exception is > widely used for error handling in python? Is it because the efficiency > is not the primary goal of python? It's not about efficiency, it's about making assumptions for the programmer about what kind of rigor th

Re: subprocess.Popen does not close pipe in an error case

2010-01-05 Thread Steven K. Wong
BTW, I'm using Python 2.6.2 on Linux. -- http://mail.python.org/mailman/listinfo/python-list

Re: please help shrink this each_with_index() implementation

2010-01-05 Thread Mackrackit
On Jan 5, 2010, at 4:30 PM, Phlip wrote: The point: int('') or int('something') both throw an error. In general, this is hand-holding, but in specific I don't think the "rich and structured" documentation will cover how to beat a 0 out of it in less than 3 lines. So I will persist in my idio

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Steven D'Aprano wrote: > On Wed, 06 Jan 2010 09:39:08 +1100, Ben Finney wrote: > >> r0g writes: >> >>> Of course I'm now guilty of pedantry too :/ I might have let it slip >>> had you not started your reply with the word "No", that just p* me >>> off. >> Well, if being told “no” is going to p

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Chris Rebert
On Tue, Jan 5, 2010 at 3:51 PM, Phlip wrote: > Peng Yu wrote: >> Otherwise, could some python expert explain to me why exception is >> widely used for error handling in python? Is it because the efficiency >> is not the primary goal of python? > > It's not about efficiency, it's about making assum

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread r0g
Lie Ryan wrote: > On 1/6/2010 1:48 AM, r0g wrote: >> Steven D'Aprano wrote: >>> On Tue, 05 Jan 2010 13:06:20 +, r0g wrote: If that's the case how can you expect it to validate anything at all in production? >>> >>> The asserts still operate so long as you don't use the -O switch.

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Phlip
On Jan 5, 5:01 pm, Chris Rebert wrote: > > Why can't int('nonnumeric') return None? > > Errors should never pass silently. You are saying I, as the programmer, cannot decide what is an error and what is a pass-thru. The decision is made for me. (Yes yes I can write int_or_None(), etc...) Here's

Re: unittest inconsistent

2010-01-05 Thread Phlip
On Jan 5, 4:14 pm, Matt Haggard wrote: > Can anyone tell me why this test fails? > > http://pastebin.com/f20039b17 > > This is a minimal example of a much more complex thing I'm trying to > do.  I'm trying to hijack a function and inspect the args passed to it > by another function. > > The reason

Re: twenty years ago Guido created Python

2010-01-05 Thread Daniel Fetchinson
>>> Python is a truly awesome programming language. Not only is Guido a >>> genius language designer, but he is also a great project leader. What >>> an accomplishment. Congratulations to everybody who has contributed >>> to Python in the last two decades! >> >> The more languages you learn befo

Re: Exception as the primary error handling mechanism?

2010-01-05 Thread Phlip
> Errors should never pass silently. > Unless explicitly silenced. > -- The Zen of Python (http://www.python.org/dev/peps/pep-0020/) "The person who says it cannot be done should never interrupt the person doing it" -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >