Re: Object Relational Mappers are evil (a meditation)

2010-01-06 Thread Ethan Furman
J Kenneth King wrote: In many contexts I'm sure there is reason to use Perl instead of Python just as there are situations where C is more appropriate than either. However, the mark of a poor programmer in my line of reasoning is one who cannot recognize such distinctions. One must be aware of

RE: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread VYAS ASHISH M-NTB837
Posting again as I did not get any response: 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

Re: unittest inconsistent

2010-01-06 Thread Peter Otten
André wrote: > On Jan 5, 8: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 f

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Ben Finney
r0g writes: > NO! It's a rude way to start a sentence don't you think? Shouting is usually rude, yes. > Just because you're correcting someone doesn't mean you have to be > combative and try and make them feel small. Again, you're reading something that isn't there. I utterly deny the motives

Re: chown'ing by script

2010-01-06 Thread Victor Subervi
On Wed, Jan 6, 2010 at 2:12 AM, alex23 wrote: > Carsten Haese wrote: > > What is the underlying problem you're trying to solve with this > > approach? > > To be paid for developing a web site shopping cart without actually > having to learn Python. > LOL! I've written about 12,000 lines of code

Need help to pass self.count to other classes.

2010-01-06 Thread Bill
After a year with Python 2.5 on my Windows box, I still have trouble understanding classes. Below, see the batch file and the configuration script for my Python interactive prompt. The widths of the secondary prompts increase when the self.count of SysPrompt1 exceeds 99. I am using a global var

Re: Need help to pass self.count to other classes.

2010-01-06 Thread Francesco Bochicchio
On 6 Gen, 11:11, Bill wrote: > After a year with Python 2.5 on my Windows box, I still have trouble > understanding classes. > > Below, see the batch file and the configuration script for > my Python interactive prompt. > > The widths of the secondary prompts increase when  the self.count of > Sys

Convert month name to month number faster

2010-01-06 Thread wiso
I'm optimizing the inner most loop of my script. I need to convert month name to month number. I'm using python 2.6 on linux x64. month_dict = {"Jan":1,"Feb":2,"Mar":3,"Apr":4, "May":5, "Jun":6, "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12} def to_dict(name): return month_dic

RE: Convert month name to month number faster

2010-01-06 Thread VYAS ASHISH M-NTB837
How about using list.index() and storing month names in a list? You may want to measure performance your self and conclude. Regards, Ashish Vyas -Original Message- From: python-list-bounces+ntb837=motorola@python.org [mailto:python-list-bounces+ntb837=motorola@python.org] On Beh

Re: Convert month name to month number faster

2010-01-06 Thread Antoine Pitrou
Le Wed, 06 Jan 2010 12:03:36 +0100, wiso a écrit : > from time import time > t = time(); xxx=map(to_dict,l); print time() - t # 0.5 t = time(); > xxx=map(to_if,l); print time() - t # 1.0 Don't define your own function just for attribute access. Instead just write: xxx = map(month_dict.__geti

[no subject]

2010-01-06 Thread Krzysztof Kobus
Hi, > Well, it seems that one of your files is a different architecture than > the others. Based on the location, I'd say it's i386 while the rest of > it would be PowerPC. You can cross-compile but you can't link an i386 > library to a PowerPC library. Thank you for the hint. I have checked with

how to change when the logging module creates the log file?

2010-01-06 Thread Chris Colbert
I have an application the writes to a log file when specific exceptions are handled. However, if no exceptions are encountered, I don't want to create a log at all. The problem I am running into is that the stdlib logging module creates the log file immediately upon logger instantiation. Thus: >>

Re: embedded python on mac - linking problem

2010-01-06 Thread Krzysztof Kobus
Hi, > > Well, it seems that one of your files is a different architecture than > > the others. Based on the location, I'd say it's i386 while the rest of > > it would be PowerPC. You can cross-compile but you can't link an i386 > > library to a PowerPC library. Thank you for the hint. I have ch

Re: Convert month name to month number faster

2010-01-06 Thread alex23
On Jan 6, 9:03 pm, wiso wrote: > I'm optimizing the inner most loop of my script. I need to convert month > name to month number. I'm using python 2.6 on linux x64. > > month_dict = {"Jan":1,"Feb":2,"Mar":3,"Apr":4, "May":5, "Jun":6, >            "Jul":7,"Aug":8,"Sep":9,"Oct":10,"Nov":11,"Dec":12}

Re: Convert month name to month number faster

2010-01-06 Thread wiso
Antoine Pitrou wrote: > Le Wed, 06 Jan 2010 12:03:36 +0100, wiso a écrit : > > >> from time import time >> t = time(); xxx=map(to_dict,l); print time() - t # 0.5 t = time(); >> xxx=map(to_if,l); print time() - t # 1.0 > > Don't define your own function just for attribute access. Instead just

creating tar file and streaming it over HTTP?

2010-01-06 Thread pbienst
I would like to bundle up a number of files in a tar file and send it over a HTTP connection, but I would like to do this without creating the tar file on disk first. I know I can get tarfile to output to a stream by doing something like tar_pipe = tarfile.open(mode="w|", fileobj=my_file_obj) Ho

Re: Convert month name to month number faster

2010-01-06 Thread Steven D'Aprano
On Wed, 06 Jan 2010 12:03:36 +0100, wiso wrote: > I'm optimizing the inner most loop of my script. I need to convert month > name to month number. I'm using python 2.6 on linux x64. According to your own figures below, it takes less than a nanosecond per lookup, at worst, even using a remarkably

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

2010-01-06 Thread Brian D
On Jan 5, 1:08 pm, Nobody wrote: > 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. > > >

Re: Need help to pass self.count to other classes.

2010-01-06 Thread Bruno Desthuilliers
Bill a écrit : After a year with Python 2.5 on my Windows box, I still have trouble understanding classes. Below, see the batch file and the configuration script for my Python interactive prompt. The widths of the secondary prompts increase when the self.count of SysPrompt1 exceeds 99. I am u

Re: Do I have to use threads?

2010-01-06 Thread Philip Semanchuk
On Jan 6, 2010, at 12:45 AM, Brian J Mingus wrote: On Tue, Jan 5, 2010 at 9:36 PM, Philip Semanchuk wrote: On Jan 5, 2010, at 11:26 PM, aditya shukla wrote: Hello people, I have 5 directories corresponding 5 different urls .I want to download images from those urls and place them in

Re: creating tar file and streaming it over HTTP?

2010-01-06 Thread Steve Holden
pbienst wrote: > I would like to bundle up a number of files in a tar file and send it > over a HTTP connection, but I would like to do this without creating > the tar file on disk first. > > I know I can get tarfile to output to a stream by doing something like > > tar_pipe = tarfile.open(mode="

Re: Do I have to use threads?

2010-01-06 Thread Brian J Mingus
On Wed, Jan 6, 2010 at 6:24 AM, Philip Semanchuk wrote: > > On Jan 6, 2010, at 12:45 AM, Brian J Mingus wrote: > > On Tue, Jan 5, 2010 at 9:36 PM, Philip Semanchuk > >wrote: >> >> >>> On Jan 5, 2010, at 11:26 PM, aditya shukla wrote: >>> >>> Hello people, >>> I have 5 directories corres

Re: Need help to pass self.count to other classes.

2010-01-06 Thread Steve Holden
Bill wrote: > After a year with Python 2.5 on my Windows box, I still have trouble > understanding classes. > > Below, see the batch file and the configuration script for > my Python interactive prompt. > > The widths of the secondary prompts increase when the self.count of > SysPrompt1 exceeds

Re: chown'ing by script

2010-01-06 Thread Steve Holden
Victor Subervi wrote: > On Wed, Jan 6, 2010 at 2:12 AM, alex23 > wrote: > > Carsten Haese > wrote: > > What is the underlying problem you're trying to solve with this > > approach? > > To be paid for developing a web

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

2010-01-06 Thread Chris Gonnerman
KvS wrote: Ok, actually I quite like being able to print straightforward through your code, i.e. without any extra modules installed. I understand that sending text to the printer is in principle as simple as dc.TextOut(scale_factor * 72, -1 * scale_factor * 72, "Testing...") I didn't s

Re: Do I have to use threads?

2010-01-06 Thread exarkun
On 04:26 am, adityashukla1...@gmail.com wrote: Hello people, I have 5 directories corresponding 5 different urls .I want to download images from those urls and place them in the respective directories.I have to extract the contents and download them simultaneously.I can extract the contents

Re: Dynamic text color

2010-01-06 Thread Neil Cerutti
On 2010-01-05, John Posner wrote: > 2. It's probably not the best idea to use a single variable > (you use "file") to do double-duty: to hold the name of a > file, and to hold the open-file object returned by the open() > function. It's perfectly legal, but it hides information that > might be

Re: embedded python on mac - linking problem

2010-01-06 Thread Diez B. Roggisch
Krzysztof Kobus schrieb: 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:

Python books, literature etc

2010-01-06 Thread Stuart Murray-Smith
Greetings list I can code in Python (strong beginner), and would like to read more books and/or online resources. Could someone please point out any good books, websites, tutorials etc to help me get to the next level. Your help && insight highly appreciated :) Stuart -- http://mail.python.org

Re: Printing plain text with exact positioning on Windows

2010-01-06 Thread KvS
On Jan 5, 7:16 pm, Nobody wrote: > 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

Re: Printing plain text with exact positioning on Windows

2010-01-06 Thread Sean DiZazzo
On Jan 5, 11:40 am, KvS wrote: > On Jan 5, 7:16 pm, Nobody wrote: > > > > > 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

Online math-coding contest

2010-01-06 Thread dhashrath govindarajan
Hi , we gladly invite you to take part in Athena - the Online Math Coding Contest of Kurukshetra 2010 , the International Techo-Management Fest organised by College Of Engineering Guindy , India under the patronage of UNESCO . Here's your chance to lock horns against the best minds across the glo

unittest inconsistent

2010-01-06 Thread Matt Haggard
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 the 'Tester' object has no attribute 'arg1' is because

Re: Printing plain text with exact positioning on Windows

2010-01-06 Thread Gerry
If this is, by any chance, an HP printer, the printer may support PCL 5 (or a similar language). I've written PCL scripts (in Pascal, so a while ago) to precisely print points at the printer resolution (i.e., I picked which six-hundredth of an inch in height and width dimensions to print a dot. PC

Re: Python books, literature etc

2010-01-06 Thread Shawn Milochik
Search Google. You'll find it all. Search this list's archives. This kind of thing has been discussed a thousand times. It also wouldn't hurt to brush up on this: http://catb.org/~esr/faqs/smart-questions.html -- http://mail.python.org/mailman/listinfo/python-list

Re: chown'ing by script

2010-01-06 Thread D'Arcy J.M. Cain
On Wed, 06 Jan 2010 08:58:13 -0500 Steve Holden wrote: > Victor Subervi wrote: [Usual nonsense removed] > Which, I don't doubt, could have been 2,000 lines had you bothered to Steve - any chance that you could stop replying to this idiot or at least do it privately. There's not much point to ki

RE: Convert month name to month number faster

2010-01-06 Thread jfabiani
VYAS ASHISH M-NTB837 wrote: > > How about using list.index() and storing month names in a list? You may > want to measure performance your self and conclude. > > Regards, > Ashish Vyas > > -Original Message- > From: python-list-bounces+ntb837=motorola@python.org > [mailto:python-li

Re: embedded python on mac - linking problem

2010-01-06 Thread Krzysztof Kobus
Hi, >The missing symbol looks like a C++-symbol - but Python is C. Do you maybe >miss the > extern "C" > > declaration. I have not specified extern "C" as I assume it is a part of PyMODINIT_FUNC define. At least documentation says so: "Note that PyMODINIT_FUNC declares the function as PyObjec

Introspection

2010-01-06 Thread m...@infoserv.dk
I'm looking for a way to make a list of string literals in a class. Example: class A: def method(self): print 'A','BC' >>> ExtractLiterals(A) ['A','BC'] Is this possible? Can anyone point me in the right direction? Thanks. /Martin -- http://mail.python.org/mailman/listinfo/python-l

Re: chown'ing by script

2010-01-06 Thread Steve Holden
D'Arcy J.M. Cain wrote: > On Wed, 06 Jan 2010 08:58:13 -0500 > Steve Holden wrote: >> Victor Subervi wrote: > [Usual nonsense removed] > >> Which, I don't doubt, could have been 2,000 lines had you bothered to > > Steve - any chance that you could stop replying to this idiot or at > least do it

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Phlip
On Jan 5, 8:49 pm, Steven D'Aprano wrote: > > (A related question - why can't I just go 'if record = method():  use > > (record)'. Why extra lines just to trap and assign the variable before > > using it?) > > Because that idiom is responsible for probably the most common error in C > of all, at

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Phlip
On Jan 5, 10:54 pm, Benjamin Kaplan wrote: > {41: None}[41] ? > > In cases where None is a valid result, you can't use it to signal failure. Asked and answered. You change the "sentinel" in .fetch to something else. But y'all keep on defending the language making your programming decisions for

Re: Python books, literature etc

2010-01-06 Thread J
On Wed, Jan 6, 2010 at 09:35, Shawn Milochik wrote: > Search Google. You'll find it all. > > Search this list's archives. This kind of thing has been discussed a thousand > times. > > It also wouldn't hurt to brush up on this: > http://catb.org/~esr/faqs/smart-questions.html Heh... I've seen tha

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Steve Holden
Phlip wrote: [...] > Don't prevent me from using a technique just because others had > trouble with it. > I presume you also campaign against anti-lock braking systems (or at least don't use cars which have them - after all, anyone who knows how to drive should be able to brake properly, right? An

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Grant Edwards
On 2010-01-06, r0g wrote: > NO! It's a rude way to start a sentence don't you think? No. When somebody asks a yes/no question, answering yes or no seems quite polite to me. Following the yes/no answer with an explanation of the answer is always nice, and I've little doubt that's what happened.

Re: Need help to pass self.count to other classes.

2010-01-06 Thread Bruno Desthuilliers
Steve Holden a écrit : (snip) This is untested code indeed !-) class kbInterface(object): def __init__(self): self.zxc = 0 def prompt1(self): self.count += 1 Ahem... (snip) -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Steve Holden
Phlip wrote: > On Jan 5, 8:49 pm, Steven D'Aprano > wrote: > >>> (A related question - why can't I just go 'if record = method(): use >>> (record)'. Why extra lines just to trap and assign the variable before >>> using it?) >> Because that idiom is responsible for probably the most common error

Re: Introspection

2010-01-06 Thread Miki
Hello Martin, > I'm looking for a way to make a list of string literals in a class. from inspect import getsourcelines from tokenize import generate_tokens, STRING, NUMBER def is_literal(t): return t[0] in (STRING, NUMBER) def get_lieterals(obj): lines, _ = getsourcelines(obj) readli

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Bruno Desthuilliers
Phlip a écrit : On Jan 5, 8:49 pm, Steven D'Aprano wrote: (A related question - why can't I just go 'if record = method(): use (record)'. Why extra lines just to trap and assign the variable before using it?) Because that idiom is responsible for probably the most common error in C of all, a

Re: Dynamic text color

2010-01-06 Thread John Posner
On Tue, 05 Jan 2010 16:54:44 -0500, Dave McCormick wrote: But it is not what I am wanting. I first thought to make it look for a space but that would not work when a single character like "#" is to be colored if there is a "string" of them. Or if all of the characters between quotes are

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Ben Kaplan
On 1/6/10 10:12 AM, Phlip wrote: On Jan 5, 10:54 pm, Benjamin Kaplan wrote: {41: None}[41] ? In cases where None is a valid result, you can't use it to signal failure. Asked and answered. You change the "sentinel" in .fetch to something else. When did I specify a sentinel value

Re: TypeError

2010-01-06 Thread MRAB
Victor Subervi wrote: Hi; I get this error: /var/www/html/angrynates.com/christians/cart/simplemail/mail.py 153 154 ''' 155 commitSale() 156 myMail() 157 print ''' commitSale = /var/www/html/angrynates.com/christians/cart

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

2010-01-06 Thread cassiope
On Jan 5, 10:58 am, Nobody wrote: > 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

Re: Introspection

2010-01-06 Thread Steven D'Aprano
On Wed, 06 Jan 2010 06:53:40 -0800, m...@infoserv.dk wrote: > I'm looking for a way to make a list of string literals in a class. > > Example: > > class A: >def method(self): >print 'A','BC' > ExtractLiterals(A) > ['A','BC'] > > Is this possible? Can anyone point me in the rig

Re: TypeError

2010-01-06 Thread Victor Subervi
On Wed, Jan 6, 2010 at 12:29 PM, MRAB wrote: > Victor Subervi wrote: > >> Hi; >> I get this error: >> >> /var/www/html/angrynates.com/christians/cart/simplemail/mail.py < >> http://angrynates.com/christians/cart/simplemail/mail.py> >> >> 153 >> 154 ''' >> 155 commitSale() >> 156 myMail() >>

Re: Need help to pass self.count to other classes.

2010-01-06 Thread Steve Holden
Bruno Desthuilliers wrote: > Steve Holden a écrit : > (snip) >> This is untested code > > indeed !-) > >> class kbInterface(object): >> def __init__(self): >> self.zxc = 0 >> def prompt1(self): >> self.count += 1 > > Ahem... > > (snip) > > Caveat emptor ... this code i

Re: creating tar file and streaming it over HTTP?

2010-01-06 Thread pbienst
Thanks for the tip! It doesn't change anything, though, so I've debugged this a little bit further. The problem seems to be that the receiving end (wsgi server) does not see the end of the data: socket = environ["wsgi.input"] while True: sys.stderr.write("be

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Phlip
Steve Holden wrote: y'all just keep defending the approach to programming that *you* think is best. Speak for yourself... -- http://mail.python.org/mailman/listinfo/python-list

Re: lxml 2.2.4 on python3.1, Windows XP gives importerror

2010-01-06 Thread Sridhar Ratnakumar
On 1/5/2010 1:38 AM, VYAS ASHISH M-NTB837 wrote: 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

Re: how to change when the logging module creates the log file?

2010-01-06 Thread Chris Colbert
i was able to fix the exception by calling logging.shutdown() before the call to os.remove(). However, I still think there is probably a more elegant solution. On Wed, Jan 6, 2010 at 12:57 PM, Chris Colbert wrote: > I have an application the writes to a log file when specific exceptions are > h

getfirst and re

2010-01-06 Thread Victor Subervi
Hi; I need to do something like the following: pat = re.compile('edit[0-9]*:[0-9]*') check = form.getfirst(pat) (to check things like 'edit0:1') How do I do this? TIA, beno -- The Logos has come to bear http://logos.13gems.com/ -- http://mail.python.org/mailman/listinfo/python-list

Python tk Listbox: -listvariable

2010-01-06 Thread Looney, James B
Yesterday, I searched all over trying to figure out how to properly use the "listvariable" argument with tk's Listbox class. Unfortunately, no amount of searching (online) could come up with anything more useful than telling me the variable needed to be a list, and nothing built-in exists. I f

Re: getfirst and re

2010-01-06 Thread Tim Chase
I need to do something like the following: pat = re.compile('edit[0-9]*:[0-9]*') check = form.getfirst(pat) (to check things like 'edit0:1') How do I do this? Well, you can do it either as check = pat.search(string_to_search) which is pretty plainly detailed in the help for the "re

Pass multidimensional array (matrix) to c function using ctypes

2010-01-06 Thread Daniel Platz
Hello, I would like to pass a two dimensional array to C function in a dll. I use ctypes to call the function. I compile the dll with visual studio 2008 express and my C source code looks like this. #include #ifdef __cplusplus extern "C" { // only need to export C interface if //

Re: getfirst and re

2010-01-06 Thread Victor Subervi
On Wed, Jan 6, 2010 at 1:27 PM, Tim Chase wrote: > But if you're using it on HTML form text, regexps are usually the wrong > tool, and you should be using an HTML parser (such as BeautifulSoup) that > knows how to handle odd text and escapings better and more robustly than > regexps will. > I hav

Re: getfirst and re

2010-01-06 Thread Tim Chase
Victor Subervi wrote: On Wed, Jan 6, 2010 at 1:27 PM, Tim Chase wrote: But if you're using it on HTML form text, regexps are usually the wrong tool, and you should be using an HTML parser (such as BeautifulSoup) that knows how to handle odd text and escapings better and more robustly than regex

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Nobody
On Tue, 05 Jan 2010 12:20:58 -0800, Marco Nawijn wrote: > You could use the build-in function enumerate inside a list > comprehension. > seq = range(5) [ (i,s) for i,s in enumerate(seq) ] > [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)] Just use list(), i.e. "list(enumerate(seq))". -- http

3 byte network ordered int, How To ?

2010-01-06 Thread mudit tuli
For a single byte, struct.pack(') For two bytes, struct.pack(') what if I want three bytes ? -- http://mail.python.org/mailman/listinfo/python-list

Re: getfirst and re

2010-01-06 Thread Victor Subervi
On Wed, Jan 6, 2010 at 1:59 PM, Tim Chase wrote: > Victor Subervi wrote: > >> On Wed, Jan 6, 2010 at 1:27 PM, Tim Chase > >wrote: >> >> But if you're using it on HTML form text, regexps are usually the wrong >>> tool, and you should be using an HTML parser (such as BeautifulSoup) that >>> knows h

File transfer with python

2010-01-06 Thread Valentin de Pablo Fouce
Hi there, I hope this is the rigth place, if not please, tell me which is the right dicussion place. I apologize in such case. Ok, I am trying to do a very quick application (is "home based" so is not a big deal...). My intention is to transfer files from one computer to another. I am using seve

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Carl Banks
On Jan 5, 2:40 pm, 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 integer > represen

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Nobody
On Tue, 05 Jan 2010 19:46:01 -0800, alex23 wrote: >> They will tell me how to use except: (which is a good example why a >> program should not use exceptions for its normal control flow if at >> all possible). > > Really? Magic functions that coerce and eat errors are a better coding > technique

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Lie Ryan
On 1/7/2010 2:12 AM, Phlip wrote: On Jan 5, 10:54 pm, Benjamin Kaplan wrote: {41: None}[41] ? In cases where None is a valid result, you can't use it to signal failure.. Asked and answered. You change the "sentinel" in .fetch to something else. I believe Ben Kaplan's point is that if dict

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Lie Ryan
On 1/7/2010 3:41 AM, Phlip wrote: Steve Holden wrote: y'all just keep defending the approach to programming that *you* think is best. Speak for yourself... Everyone speaks for themselves, is that a problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: 3 byte network ordered int, How To ?

2010-01-06 Thread Matthew Barnett
mudit tuli wrote: For a single byte, struct.pack(') For two bytes, struct.pack(') what if I want three bytes ? Four bytes and then discard the most-significant byte: struct.pack(')[ : -1] -- http://mail.python.org/mailman/listinfo/python-list

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

2010-01-06 Thread Nobody
On Tue, 05 Jan 2010 15:50:39 -0800, Steven K. Wong wrote: > 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, the

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

2010-01-06 Thread Heikki Toivonen
News123 wrote: > This will probably work, but it requires the module M2Crypto. > > In order to avoid installing M2Crypto an all hosts that want to run the > script I wondered, whether there is no other solution. > > I can do xmlrpc over ssl WITHOUT certificates with following code: [...] Please

Re: File transfer with python

2010-01-06 Thread Lie Ryan
On 1/7/2010 5:00 AM, Valentin de Pablo Fouce wrote: My intention is to be able to transfer files from one computer to another in this environment. Do you have a USB flashdrive? Looking (and surfing) at internet the only suggestion given is to use low level sockets for this file transfer. Is t

Re: Python books, literature etc

2010-01-06 Thread J
A good point was brought up to me privately, and I agree completely, that the OP should re-state the request with a bit more specifics... Since the OP says he is at least familiar with Python, does he need info on beginner level books that are general purpose, or is he interested in resources that

Re: suds problem

2010-01-06 Thread Fencer
On 2010-01-06 19:33, Fencer wrote: Hello, I just started using suds to use web services. First I tried suds with a very simple web service I had written and was running myself. That worked fine. Then I tried to use the web services provided by KEGG: http://soap.genome.jp/KEGG.wsdl But I get a SAX

Re: getfirst and re

2010-01-06 Thread Carsten Haese
Victor Subervi wrote: > I have an automatically generated HTML form from which I need to extract > data to the script which this form calls (to which the information is > sent). Ideally, the script that receives the submitted fields should know how the form was generated, so it knows what fields t

Re: getfirst and re

2010-01-06 Thread Victor Subervi
On Wed, Jan 6, 2010 at 3:09 PM, Carsten Haese wrote: > Victor Subervi wrote: > > I have an automatically generated HTML form from which I need to extract > > data to the script which this form calls (to which the information is > > sent). > > Ideally, the script that receives the submitted fields

Astronomy--Programs to Compute Siderial Time?

2010-01-06 Thread W. eWatson
Is there a smallish Python library of basic astronomical functions? There are a number of large such libraries that are crammed with excessive functions not needed for common calculations. -- http://mail.python.org/mailman/listinfo/python-list

Need help with multiprocessing.manager and passing the manager a multiprocessing.Connection

2010-01-06 Thread Metalone
The following code snippet is taken from the Python 2.6 multiprocessing documentation with a simple change and this change does not work. I would like to know how to make it work or something similar. I want to pass a Connection object to the MathsClass. I get the following error on Windows: Trac

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

2010-01-06 Thread Steven K. Wong
On Jan 6, 10:30 am, Nobody wrote: > I think that you should close prog1.stdout here. Otherwise, there will > be two readers on the pipe (the calling process and prog2). Even if one of > them dies, there's always the possibility that the caller might eventually > decide to read prog1.stdout itself.

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Grant Edwards
On 2010-01-06, Lie Ryan wrote: > On 1/7/2010 3:41 AM, Phlip wrote: >> Steve Holden wrote: >> >>> y'all just keep defending the approach to programming that >>> *you* think is best. >> >> Speak for yourself... > > Everyone speaks for themselves, [...] Except for the Lorax. He speaks for the trees

The END (of PyCon early bird registration) is NEAR!

2010-01-06 Thread VanL
Today is the last day of registration for PyCon 2010 at the early bird rate. Registration at the early bird rate is still good as long as it is January 6 somewhere in the world. Register now! - https://us.pycon.org/2010/register/ -- http://mail.python.org/mailman/listinfo/python-list

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Phlip
Nobody wrote: On Tue, 05 Jan 2010 19:46:01 -0800, alex23 wrote: They will tell me how to use except: (which is a good example why a program should not use exceptions for its normal control flow if at all possible). Really? Magic functions that coerce and eat errors are a better coding techniqu

an't start a thread Pool from another thread

2010-01-06 Thread Glazner
Hi all, I hope someone can help me with this issue I see that i can't start a thread Pool from another thread, why? running python 2.6.4 windowsXP >>> import multiprocessing.dummy as threads >>> def makePool(): threads.Pool(3) >>> makePool() >>> import thread >>> thread.start_new(makePool

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Phlip
On Jan 6, 10:23 am, Lie Ryan wrote: > On 1/7/2010 3:41 AM, Phlip wrote: > > > Steve Holden wrote: > > >> y'all just keep defending the approach to programming that > >> *you* think is best. > > > Speak for yourself... > > Everyone speaks for themselves, is that a problem? Of course not. I was poi

Mencoder and creating videos

2010-01-06 Thread aditya shukla
Hello Guys, I have a multiprocessing script which downloads images from 5 urls to 5 directories(usinf multiprocess in python 2.6).The download is for 5 mins.My aim is to create a video for every minute for each directory and dump the images as the video is created. My question are , should i use *

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Terry Reedy
On 1/6/2010 1:20 PM, Lie Ryan wrote: Python decided that the default behavior should be raising exception and sentinel have to use the dict.get() method. Simple and clear. The other possible behavior (i.e. slicing returns a sentinel while dict.get() raises an exception) is arguably just as simpl

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Steven D'Aprano
On Wed, 06 Jan 2010 12:39:36 -0800, Phlip wrote: > And now, if everyone will excuse me, I have to get back to writing a > unit-test-to-code ratio of 2:1. In my experience, that's about half as many unit-tests as needed for full code coverage for even a simple class. If you're trying to impress u

Re: Introspection

2010-01-06 Thread Jason Scheirer
On Jan 6, 8:38 am, Steven D'Aprano wrote: > On Wed, 06 Jan 2010 06:53:40 -0800, m...@infoserv.dk wrote: > > I'm looking for a way to make a list of string literals in a class. > > > Example: > > > class A: > >    def method(self): > >        print 'A','BC' > > ExtractLiterals(A) > > ['A','BC'

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Steven D'Aprano
On Wed, 06 Jan 2010 12:12:08 -0800, Phlip wrote: > And I, not my language, should pick and chose how to be rigorous. The > language should not make the decision for me. All languages make that decision for you by making some thing possible and other things not. The language designer, not the pro

QDoubleValidator

2010-01-06 Thread Zabin
Hey! I am new PyQt programmer and want to restrict users to allow only numeric values into a table and lineedit boxes. I found the QDoubleValidator class but am unsure as to how to implement it. (I am a little shaky on the concept of parent and how to define them). Any help would be much appreciat

Re: Exception as the primary error handling mechanism?

2010-01-06 Thread Steve Holden
Phlip wrote: > On Jan 6, 10:23 am, Lie Ryan wrote: >> On 1/7/2010 3:41 AM, Phlip wrote: >> >>> Steve Holden wrote: y'all just keep defending the approach to programming that *you* think is best. >>> Speak for yourself... >> Everyone speaks for themselves, is that a problem? > > Of cours

Re: File transfer with python

2010-01-06 Thread Jan Kaliszewski
Valentin de Pablo Fouce wrote: Ok, I am trying to do a very quick application (is "home based" so is not a big deal...). My intention is to transfer files from one computer to another. My intention is to be able to transfer files from one computer to another in this environment. Looking (an

Re: creating tar file and streaming it over HTTP?

2010-01-06 Thread r0g
pbienst wrote: > I would like to bundle up a number of files in a tar file and send it > over a HTTP connection, but I would like to do this without creating > the tar file on disk first. > Stringio lets you treat a strings as a files... http://docs.python.org/library/stringio.html Roger. -- h

Re: Mencoder and creating videos

2010-01-06 Thread Emile van Sebille
On 1/6/2010 12:44 PM aditya shukla said... Hello Guys, I have a multiprocessing script which downloads images from 5 urls to 5 directories(usinf multiprocess in python 2.6).The download is for 5 mins.My aim is to create a video for every minute for each directory and dump the images as the video

  1   2   >