Re: Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-01 Thread Terry Reedy
On 1/1/2010 8:57 PM, Benjamin Kaplan wrote: As far as Windows file associations go, I suppose the most recent install would dominate though you could always reset the associations yourself. The Windows installer asks whether one wants the about-to-be-installed version to capture the associati

Re: multivariable assignment

2010-01-01 Thread Rainer Grimm
On Dec 31 2009, 5:13 pm, davidj411 wrote: > I am not sure why this behavior is this way. > at beginning of script, i want to create a bunch of empty lists and > use each one for its own purpose. > however, updating one list seems to update the others. > > >>> a = b = c = [] > >>> a.append('1') > >

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Aahz
In article <4b3dcfab.3030...@v.loewis.de>, Martin v. Loewis wrote: > >Notice that in cases where the failure may be expected, Python >also offers variants that avoid the exception: >- if you look into a dictionary, expecting that a key may not > be there, a regular access, d[k], may give a KeyErr

Re: Raw string substitution problem

2010-01-01 Thread Aahz
In article <7p2juvfu8...@mid.individual.net>, Gregory Ewing wrote: >MRAB wrote: >> >> In simple cases you might be replacing with the same string every time, >> but other cases you might want the replacement to contain substrings >> captured by the regex. > >But you can give it a function that ha

Re: Significant whitespace

2010-01-01 Thread Chris Rebert
On Fri, Jan 1, 2010 at 9:56 PM, Donn wrote: > On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote: >> I put together a page about significant whitespace (and the lack thereof). > The only thing about Python's style that worries me is that it can't be > compressed like javascript can*, and per

Re: Significant whitespace

2010-01-01 Thread Donn
On Saturday 02 January 2010 00:02:36 Dan Stromberg wrote: > I put together a page about significant whitespace (and the lack thereof). The only thing about Python's style that worries me is that it can't be compressed like javascript can*, and perhaps that will prevent it becoming a browser-side

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-01 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Diez B. Roggisch wrote: > AFAIK, sqlite ensures process-serialization via locking, and threads > synchronize themselves as well. SQLite versions prior to 3.5 did not support using the same connection or cursors in different threads. (You needed to al

Re: Significant whitespace

2010-01-01 Thread Roy Smith
In article <3db95947-1e35-4bd1-bd4c-37df646f9...@v25g2000yqk.googlegroups.com>, John Machin wrote: > On Jan 2, 10:29 am, Roy Smith wrote: > > > > > To address your question more directly, here's a couple of ways Fortran > > treated whitespace which would surprise the current crop of > > Java/

Re: Significant whitespace

2010-01-01 Thread MRAB
Dan Stromberg wrote: I put together a page about significant whitespace (and the lack thereof). You're invited to check it out: http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html You might also want to mention that programmers tend to indent anyway for clarity. -- http://m

Re: Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-01 Thread Benjamin Kaplan
On Fri, Jan 1, 2010 at 8:37 PM, W. eWatson wrote: > I suspect that if one installs v2.4 and 2.5, or any two versions, that one > will dominate, or there will be a conflict.  I suppose it would not be > possible to choose which one should be used. Comments? > -- > http://mail.python.org/mailman/lis

Re: Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-01 Thread Benjamin Kaplan
The convention (more used among Unix variants but I guess the same thing applies to Windows if you're setting the system path) is that running "python" from the command line will give you the most recently installed one. If you want to specify a version, it would be "python24" or "python25". Each v

Re: Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-01 Thread alex23
On Jan 2, 11:37 am, "W. eWatson" wrote: > I suspect that if one installs v2.4 and 2.5, or any two versions, that > one will dominate, or there will be a conflict.  I suppose it would not > be possible to choose which one should be used. Comments? I suspect that you're not the first person to ask

Potential Conflicts by Installing Two Versions of Python (Windows)?

2010-01-01 Thread W. eWatson
I suspect that if one installs v2.4 and 2.5, or any two versions, that one will dominate, or there will be a conflict. I suppose it would not be possible to choose which one should be used. Comments? -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Peng Yu
On Thu, Dec 31, 2009 at 11:24 PM, Chris Rebert wrote: > On Thu, Dec 31, 2009 at 8:47 PM, Peng Yu wrote: >> I observe that python library primarily use exception for error >> handling rather than use error code. >> >> In the article API Design Matters by Michi Henning >> >> Communications of the A

Re: Significant whitespace

2010-01-01 Thread Steven D'Aprano
On Fri, 01 Jan 2010 14:19:28 -0800, Chris Rebert wrote: > For those of us who weren't around during the heyday of FORTRAN, can > anyone describe this apparently much-reviled significant whitespace > feature that continues to make some programmers unjustly fearful about > Python's use of indentatio

Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2010-01-01 Thread Jonathan Hartley
> the method involves editing python26.dll in order to remove > dependency references and then dropping msvcr90.dll in the same > directory as the py2exe produced executable. Clever idea Waldemar, thanks for that, but for the moment, using the dll as a win32 assembly (ie. with a manifest file, as

Re: Significant whitespace

2010-01-01 Thread Roy Smith
In article , Chris Rebert wrote: > On Fri, Jan 1, 2010 at 2:02 PM, Dan Stromberg wrote: > > I put together a page about significant whitespace (and the lack thereof). > > > > You're invited to check it out: > > > > http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html > > For t

Re: Trying to run a sudo command from script

2010-01-01 Thread Diez B. Roggisch
Kent Tenney schrieb: Howdy, A script running as a regular user sometimes wants to run sudo commands. It gets the password with getpass. pw = getpass.getpass() I've fiddled a bunch with stuff like proc = subprocess.Popen('sudo touch /etc/foo'.split(), stdin=subprocess.PIPE) proc.communicate(inp

Trying to run a sudo command from script

2010-01-01 Thread Kent Tenney
Howdy, A script running as a regular user sometimes wants to run sudo commands. It gets the password with getpass. pw = getpass.getpass() I've fiddled a bunch with stuff like proc = subprocess.Popen('sudo touch /etc/foo'.split(), stdin=subprocess.PIPE) proc.communicate(input=pw) getting assorte

Re: twenty years ago Guido created Python

2010-01-01 Thread dennis
On Jan 1, 6:04 am, Krishnakant wrote: > On Fri, 2010-01-01 at 03:25 -0800, J Peyret wrote: > > On Dec 31 2009, 2:06 pm, Steve Howell wrote: > > > FYI: > > > >http://twitter.com/gvanrossum > > > > Python is a truly awesome programming language.  Not only is Guido a > > > genius language designer,

Re: Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-01 Thread Diez B. Roggisch
pyt...@bdurham.com schrieb: I'm looking for the best practice way for a multi-threaded python web server application to read/write to a shared file or a SQLite database. What do I need to do (if anything) to make sure my writes to a regular file on disk or to a SQLite database are atomic in natu

Re: Significant whitespace

2010-01-01 Thread Chris Rebert
On Fri, Jan 1, 2010 at 2:02 PM, Dan Stromberg wrote: > I put together a page about significant whitespace (and the lack thereof). > > You're invited to check it out: > > http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html For those of us who weren't around during the heyday of F

Significant whitespace

2010-01-01 Thread Dan Stromberg
I put together a page about significant whitespace (and the lack thereof). You're invited to check it out: http://stromberg.dnsalias.org/~dstromberg/significant-whitespace.html -- http://mail.python.org/mailman/listinfo/python-list

Safe file I/O to shared file (or SQLite) from multi-threaded web server

2010-01-01 Thread python
I'm looking for the best practice way for a multi-threaded python web server application to read/write to a shared file or a SQLite database. What do I need to do (if anything) to make sure my writes to a regular file on disk or to a SQLite database are atomic in nature when multiple clients post

Re: Which version of MSVC?90.DLL's to distribute with Python 2.6 based Py2exe executables?

2010-01-01 Thread python
Waldemar, Thank your for sharing your technique - works great with 32-bit Python 2.6.4. Has anyone tried this with a 64-bit version of Python? Malcolm -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQL Error

2010-01-01 Thread MRAB
Benjamin Kaplan wrote: On Fri, Jan 1, 2010 at 1:32 PM, Victor Subervi wrote: On Fri, Jan 1, 2010 at 12:10 PM, MRAB wrote: Victor Subervi wrote: Hi; I'm trying to avoid the mortal sin of blank excepts. I intentionally threw this error: Traceback (most recent call last): File "/var/www/html/

Re: MySQL Error

2010-01-01 Thread Benjamin Kaplan
On Fri, Jan 1, 2010 at 1:32 PM, Victor Subervi wrote: > On Fri, Jan 1, 2010 at 12:10 PM, MRAB wrote: >> >> Victor Subervi wrote: >>> >>> Hi; >>> I'm trying to avoid the mortal sin of blank excepts. I intentionally >>> threw this error: >>> >>> Traceback (most recent call last): >>>  File "/var/ww

Re: How to Suppress Interactive Assignment to "_"

2010-01-01 Thread JKPeck
On Jan 1, 10:06 am, Peter Otten <__pete...@web.de> wrote: > JKPeck wrote: > > The gettext module uses the convention of defining a function named > > "_" that maps text into its translation. > > This conflicts with the automatic interactive interpreter assignment > > of expressions to a variable wi

Re: twenty years ago Guido created Python

2010-01-01 Thread Steve Howell
On Jan 1, 9:03 am, MRAB wrote: > J Peyret wrote: > > On Dec 31 2009, 2:06 pm, Steve Howell wrote: > >> FYI: > > >>http://twitter.com/gvanrossum > > >> Python is a truly awesome programming language.  Not only is Guido a > >> genius language designer, but he is also a great project leader.  What >

Re: MySQL Error

2010-01-01 Thread Victor Subervi
On Fri, Jan 1, 2010 at 12:10 PM, MRAB wrote: > Victor Subervi wrote: > >> Hi; >> I'm trying to avoid the mortal sin of blank excepts. I intentionally threw >> this error: >> >> Traceback (most recent call last): >> File "/var/www/html/angrynates.com/cart/createAssociations2.py < >> http://angryn

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Martin v. Loewis
> You do understand that exceptions aren't just for errors? They are raised > under specific circumstances. Whether that circumstance is an error or > not is entirely up to the caller. I think that's a fairly narrow definition of the word error, and probably also the source of confusion in this

Re: How to Suppress Interactive Assignment to "_"

2010-01-01 Thread Peter Otten
JKPeck wrote: > The gettext module uses the convention of defining a function named > "_" that maps text into its translation. > This conflicts with the automatic interactive interpreter assignment > of expressions to a variable with that same name. > > While if you are careful, you can avoid tha

Re: MySQL Error

2010-01-01 Thread MRAB
Victor Subervi wrote: Hi; I'm trying to avoid the mortal sin of blank excepts. I intentionally threw this error: Traceback (most recent call last): File "/var/www/html/angrynates.com/cart/createAssociations2.py ", line 137, in ? create

Re: MySQL Error

2010-01-01 Thread Carsten Haese
Victor Subervi wrote: > However, "ProgrammingError" is not an error. How do I discover the real > error, so I can write the appropriate except statement? You're not making any sense. How did you determine that ProgrammingError is not an error or that it's not the "real error"? Show us the code you

Re: twenty years ago Guido created Python

2010-01-01 Thread MRAB
J Peyret wrote: On Dec 31 2009, 2:06 pm, Steve Howell wrote: FYI: http://twitter.com/gvanrossum 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

MySQL Error

2010-01-01 Thread Victor Subervi
Hi; I'm trying to avoid the mortal sin of blank excepts. I intentionally threw this error: Traceback (most recent call last): File "/var/www/html/angrynates.com/cart/createAssociations2.py", line 137, in ? createAssociations2() File "/var/www/html/angrynates.com/cart/createAssociations2.py

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Steven D'Aprano
On Fri, 01 Jan 2010 11:02:28 -0500, Benjamin Kaplan wrote: > I was trying to point out that in > Python, you don't test errors for your typical conditions, but for ones > that you know still exist but don't plan on occurring often. I'm sorry, but that makes no sense to me at all. I don't understa

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Mel
Steven D'Aprano wrote: > On Fri, 01 Jan 2010 02:43:21 -0800, Jonathan Gardner wrote: > >> On Jan 1, 12:43 am, a...@pythoncraft.com (Aahz) wrote: >>> In article , >>> Benjamin Kaplan wrote: >>> >In Python, throwing exceptions for expected outcomes is considered >>> >very bad form [...] >>> >>> W

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Benjamin Kaplan
On Fri, Jan 1, 2010 at 9:49 AM, Steven D'Aprano wrote: > > Exceptions are *exceptional*, not "errors" or "unexpected". They are > exceptional because they aren't the "normal" case, but that doesn't mean > they are surprising or unexpected. Are you surprised that your "for x in > range(1000)" loop

How to Suppress Interactive Assignment to "_"

2010-01-01 Thread JKPeck
The gettext module uses the convention of defining a function named "_" that maps text into its translation. This conflicts with the automatic interactive interpreter assignment of expressions to a variable with that same name. While if you are careful, you can avoid that assignment while debuggin

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Lie Ryan
On 1/1/2010 3:47 PM, Peng Yu wrote: I observe that python library primarily use exception for error handling rather than use error code. In the article API Design Matters by Michi Henning Communications of the ACM Vol. 52 No. 5, Pages 46-56 10.1145/1506409.1506424 http://cacm.acm.org/magazines/

Re: change an exception's message and re-raise it

2010-01-01 Thread Phlip
On Dec 31 2009, 4:30 pm, Steven D'Aprano wrote: > For the record you can get the exception type from type(e): > > raise type(e)("whatever you want") > > but that creates a new exception, not re-raising the old one. Except if a type constructs with some other number of arguments, apparently... --

Re: change an exception's message and re-raise it

2010-01-01 Thread Phlip
On Dec 31 2009, 4:30 pm, Steven D'Aprano wrote: > ...     1/0 > ... except ZeroDivisionError, e: > ...     e.args = e.args + ('fe', 'fi', 'fo', 'fum') > ...     raise When I added print e.args it showed the old args. Maybe I was trying too hard - this is why I said e seemed locked or something.

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Steven D'Aprano
On Fri, 01 Jan 2010 00:26:09 -0500, Benjamin Kaplan wrote: > On Thu, Dec 31, 2009 at 11:47 PM, Peng Yu wrote: >> I observe that python library primarily use exception for error >> handling rather than use error code. >> >> In the article API Design Matters by Michi Henning >> >> Communications of

Re: Dangerous behavior of list(generator)

2010-01-01 Thread Steven D'Aprano
On Fri, 01 Jan 2010 05:19:02 -0800, Wolfram Hinderer wrote: > On 1 Jan., 02:47, Steven D'Aprano cybersource.com.au> wrote: >> On Thu, 31 Dec 2009 11:34:39 -0800, Tom Machinski wrote: [...] >> > As for what's wrong with the "if not any" solution, Benjamin Kaplan's >> > post hits the nail on its he

Re: Where is "urllib2" module in windows python3.1.1?

2010-01-01 Thread Lie Ryan
On 1/2/2010 12:46 AM, Hidekazu IWAKI wrote: Hi; I'd like to import "urllib2" in windows python 3.1.1, but I'm not able to do it. So, I researched the library directory; the result is following: . . 2009/06/07 19:1161,749 unittest.py 2010/01/01 22:18 urllib 2007/12

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Steven D'Aprano
On Fri, 01 Jan 2010 02:43:21 -0800, Jonathan Gardner wrote: > On Jan 1, 12:43 am, a...@pythoncraft.com (Aahz) wrote: >> In article , >> Benjamin Kaplan   wrote: >> >In Python, throwing exceptions for expected outcomes is considered >> >very bad form [...] >> >> Who says that?  I certainly don't. >

Re: Where is "urllib2" module in windows python3.1.1?

2010-01-01 Thread IWAKI, Hidekazu
>Python 3 doesn't have a urllib2 module; use the urllib package instead. Thank you for your answer and the link. Oh, sorry. It was one of the changes from .2.x to 3.x. I didn't know. There are really important and a lot of changes. Thank you! On Fri, Jan 1, 2010 at 10:57 PM, Duncan Booth wrote:

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Andreas Waldenburger
On Fri, 01 Jan 2010 11:34:19 +0100 "Martin v. Loewis" wrote: > Your observation is not wrong, but, as Benjamin already explained, > you are misinterpreting Michi Henning's statement. He doesn't condemn > exception handling per se, but only for the handling of *expected* > outcomes. He would consi

Re: Where is "urllib2" module in windows python3.1.1?

2010-01-01 Thread Duncan Booth
Hidekazu IWAKI wrote: > Hi; > I'd like to import "urllib2" in windows python 3.1.1, but I'm not able to > do it. Python 3 doesn't have a urllib2 module; use the urllib package instead. See http://www.python.org/dev/peps/pep-3108/#urllib-package -- http://mail.python.org/mailman/listinfo/python

Where is "urllib2" module in windows python3.1.1?

2010-01-01 Thread Hidekazu IWAKI
Hi; I'd like to import "urllib2" in windows python 3.1.1, but I'm not able to do it. So, I researched the library directory; the result is following: 2009/06/07 19:1161,749 unittest.py 2010/01/01 22:18 urllib 2007/12/06 09:48 6,318 uu.py 2008/11/30

Re: Dangerous behavior of list(generator)

2010-01-01 Thread Wolfram Hinderer
On 1 Jan., 02:47, Steven D'Aprano wrote: > On Thu, 31 Dec 2009 11:34:39 -0800, Tom Machinski wrote: > > On Wed, Dec 30, 2009 at 4:01 PM, Steven D'Aprano > > wrote: > >> On Wed, 30 Dec 2009 15:18:11 -0800, Tom Machinski wrote: > >>> Bottom line, I'm going to have to remove this pattern from my c

Re: multivariable assignment

2010-01-01 Thread Lie Ryan
On 1/1/2010 3:13 AM, davidj411 wrote: I am not sure why this behavior is this way. at beginning of script, i want to create a bunch of empty lists and use each one for its own purpose. however, updating one list seems to update the others. a = b = c = [] a.append('1') a.append('1') a.append('1'

Re: adding python engine into c++ application

2010-01-01 Thread bobicanprogram
On Dec 29 2009, 6:25 am, griwes wrote: > Hello, I am going to write an application in C++, application which > should be easy to extend by scripts. I chose python for script > language in this application. I'd like to have own API for python. And > here the question arises: how do I implement a py

Re: twenty years ago Guido created Python

2010-01-01 Thread Krishnakant
On Fri, 2010-01-01 at 03:25 -0800, J Peyret wrote: > On Dec 31 2009, 2:06 pm, Steve Howell wrote: > > FYI: > > > > http://twitter.com/gvanrossum > > > > Python is a truly awesome programming language. Not only is Guido a > > genius language designer, but he is also a great project leader. What >

Re: pywinauto to show the dialog , menu, etc

2010-01-01 Thread Simon Brunning
2009/12/31 Hari : > Hi > I am using pywinauto to automate an custom program to startup and load > process , execute etc. But cannot determine menuselect. Is there a way or > tool which can run against the exe to show the menu, dialog box, list box > which are contained within it. Winspector might

Re: twenty years ago Guido created Python

2010-01-01 Thread J Peyret
On Dec 31 2009, 2:06 pm, Steve Howell wrote: > FYI: > > http://twitter.com/gvanrossum > > 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 contrib

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Jonathan Gardner
On Jan 1, 12:43 am, a...@pythoncraft.com (Aahz) wrote: > In article , > Benjamin Kaplan   wrote: > >In Python, throwing exceptions for expected outcomes is considered > >very bad form [...] > > Who says that?  I certainly don't. Agreed. int("asdf") is supposed to return what, exactly? Any languag

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Martin v. Loewis
Peng Yu wrote: > I observe that python library primarily use exception for error > handling rather than use error code. [...] > It says "Another popular design flaw—namely, throwing exceptions for > expected outcomes—also causes inefficiencies because catching and > handling exceptions is almost al

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Aahz
In article , Benjamin Kaplan wrote: > >In Python, throwing exceptions for expected outcomes is considered >very bad form [...] Who says that? I certainly don't. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ Weinberg's Second Law: If builders built buildings

Re: Not Incrementing

2010-01-01 Thread Victor Subervi
On Fri, Jan 1, 2010 at 2:47 AM, Victor Subervi wrote: > On Thu, Dec 31, 2009 at 3:46 PM, MRAB wrote: > >> Victor Subervi wrote: >> >>> On Thu, Dec 31, 2009 at 3:01 PM, MRAB >> pyt...@mrabarnett.plus.com>> wrote: >>> >>>Victor Subervi wrote: >>> >>>On Thu, Dec 31, 2009 at 1:01 PM, Dave

Re: Exception as the primary error handling mechanism?

2010-01-01 Thread Steven D'Aprano
On Thu, 31 Dec 2009 20:47:49 -0800, Peng Yu wrote: > I observe that python library primarily use exception for error handling > rather than use error code. > > In the article API Design Matters by Michi Henning > > Communications of the ACM > Vol. 52 No. 5, Pages 46-56 > 10.1145/1506409.1506424