Re: changing current dir and executing a shell script

2011-05-28 Thread Peter Otten
Albert Hopkins wrote: > On Fri, 2011-05-27 at 14:25 -0700, suresh wrote: >> I want to execute the following command line stuff from inside python. >> $cd directory >> $./executable >> >> I tried the following but I get errors >> import subprocess >> subprocess.check_call('cd dir_name;./executabl

Re: Beginner needs advice

2011-05-28 Thread Steven D'Aprano
On Sat, 28 May 2011 08:38:54 +0200, Thorsten Kampe wrote: > * Thomas Rachel (Sat, 28 May 2011 07:06:53 +0200) >> Am 27.05.2011 17:52 schrieb Steven D'Aprano: >> > On Fri, 27 May 2011 09:40:53 -0500, harrismh777 wrote: >> >> 3.x is completely incompatible with 2.x (some call it a dialect, but >> >>

Re: The worth of comments

2011-05-28 Thread Gregory Ewing
Grant Edwards wrote: After hearing/reading somebody for years, I don't seem to have a detailed image of them in my head, but when I finally do see a picture of them, my initial reaction is almost always "no, that's not at all what I thought he/she looked like". It works the other way, too. I'v

Re: GIL in alternative implementations

2011-05-28 Thread Marc Christiansen
Daniel Kluev wrote: > test.py: > > from threading import Thread > class X(object): >pass > obj = X() > obj.x = 0 > > def f(*args): > for i in range(1): > obj.x += 1 > > threads = [] > for i in range(100): >t = Thread(target=f) >threads.append(t) >t.start() > > for t

Re: GIL in alternative implementations

2011-05-28 Thread Peter Otten
Daniel Kluev wrote: >> So I'd like to know: how do these other implementations handle >> concurrency matters for their primitive types, and prevent them from >> getting corrupted in multithreaded programs (if they do) ? I'm not only >> thinking about python types, but also primitive containers and

Re: GIL in alternative implementations

2011-05-28 Thread Wolfgang Rohdewald
On Samstag 28 Mai 2011, Marc Christiansen wrote: > And I wouldn't rely on 3.2 > not to break. it breaks too like it should, but only rarely like one out of 10 times i5:/pub/src/gitgames/kajongg/src$ python3.2 test.py 100 i5:/pub/src/gitgames/kajongg/src$ python3.2 test.py 100 i5:/pub/sr

Re: Question about isodate

2011-05-28 Thread Colin J. Williams
On 26-May-11 07:48 AM, truongxuan quang wrote: Hello list, I am installing and testing istSOS wrote base on Python with its extension like gdal, isodate, easy istall, setuptool, psycopg. I have already installed all these stuff when I was using method POST the error appear is "_No module named m

Re: and becomes or and or becomes and

2011-05-28 Thread bch
On May 23, 11:30 pm, rusi wrote: > On May 23, 5:30 am, Steven D'Aprano > > > +comp.lang.pyt...@pearwood.info> wrote: > > On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote: > > > Stef Mientki wrote: > > > >>must of us will not use single bits these days, but at first sight, this > > >>looks f

Re: Beginner needs advice

2011-05-28 Thread D'Arcy J.M. Cain
On Sat, 28 May 2011 07:06:53 +0200 Thomas Rachel wrote: > > "Completely incompatible"? A "lie"? > > Hard word, but it is true. Many things can and will fall on your feet > when moving. > > There are very many subtle differences. The space between "Completely incompatible" and "many subtle diff

Re: Why did Quora choose Python for its development?

2011-05-28 Thread Roy Smith
In article , Carl Banks wrote: > On Friday, May 27, 2011 6:47:21 AM UTC-7, Roy Smith wrote: > > One of the truly awesome things about the Python re library is that it > > lets you write complex regexes like this: > > > > pattern = r"""\b # beginning of line > >

Re: and becomes or and or becomes and

2011-05-28 Thread Chris Angelico
On Sat, May 28, 2011 at 10:27 PM, bch wrote: > And of course, a programmer cannot tell the difference between > Halloween and Christmas day. Well known, of course. But a lot of modern programmers don't speak octal, they only use another power-of-two base; it's as though someone's cast a hex on th

Re: The worth of comments

2011-05-28 Thread Irmen de Jong
On 27-5-2011 19:53, Grant Edwards wrote: > On 2011-05-27, Irmen de Jong wrote: >> On 27-05-11 15:54, Grant Edwards wrote: >>> On 2011-05-27, Ben Finney wrote: Richard Parker writes: > On May 26, 2011, at 4:28 AM, python-list-requ...@python.org wrote: > >> My experience is t

Re: The worth of comments

2011-05-28 Thread python
Irmen, > I'm going to share this thread, and the funny slideshow about Uncomment your > code, with my team at work :-) We're not a Python shop so I'm probably the > only one reading this Same here! > but as usual there is a lot of wisdom going on in this new[s]group that is > not only applica

Re: and becomes or and or becomes and

2011-05-28 Thread Nobody
On Sun, 22 May 2011 15:39:33 -0700, Tim Roberts wrote: > That IS funny. Interesting how a careful choice of arugments will fool us. > One of my favorite math jokes is like that. A teacher asked a student to > reduce the following fraction: > 16 > > 64 > > He says "all I have to do is

join this group

2011-05-28 Thread YUVI RAJ
http://123maza.com/65/Cape201/ -- http://mail.python.org/mailman/listinfo/python-list

Re: The worth of comments

2011-05-28 Thread Roy Smith
In article , Grant Edwards wrote: > When trying to find a bug in code written by sombody else, I often > first go through and delete all of the comments so as not to be > mislead. I've heard people say that before. While I get the concept, I don't like doing things that way myself. >> The co

join this group

2011-05-28 Thread YUVI RAJ
http://123maza.com/65/Cape201/ -- http://mail.python.org/mailman/listinfo/python-list

PyCon Australia 2011: Early Bird Closing Soon

2011-05-28 Thread Ryan Kelly
Hi Everyone, A reminder that Early Bird Registrations for PyCon Australia 2011 will be closing soon. There are only a few days left to get your tickets at the discounted rate. PyCon Australia is Australia's only conference dedicated exclusively to the Python programming language, and will be h

Re: The worth of comments

2011-05-28 Thread Chris Angelico
On Sat, May 28, 2011 at 11:36 PM, Roy Smith wrote: > def foo(): >   "Raise IndexError.  This is useful as a testing fixture." >   l = [1, 2, 3] >   return l[3] A quite useful thing, on occasion. I have a couple of variants of this, actually. In one of my C++ programs: extern char *death1; extern

Re: and becomes or and or becomes and

2011-05-28 Thread Chris Angelico
On Sat, May 28, 2011 at 11:31 PM, Nobody wrote: > Not Python, but: > >        #define SIX  1 + 5 >        #define NINE 8 + 1 >        ... >        printf("six times nine is: %d\n", SIX * NINE); *AWESOME*!! That is brilliant! DNA FTW. ChrisA -- http://mail.python.org/mailman/listinfo/python-lis

Re: The worth of comments

2011-05-28 Thread Irmen de Jong
On 28-5-2011 15:36, Roy Smith wrote: > In article , > Grant Edwards wrote: > >> When trying to find a bug in code written by sombody else, I often >> first go through and delete all of the comments so as not to be >> mislead. > > I've heard people say that before. While I get the concept, I do

How to catch a line with Popen

2011-05-28 Thread TheSaint
Hello. I'm looking into subprocess.Popen docs. I've launch the program with its arguments and that's smooth. I'm expecting to read the output by *comunicate()* at every line that prgram may blow during the process, but the output is given only when the child process is ended. I'd like to process

Re: GIL in alternative implementations

2011-05-28 Thread John Nagle
On 5/27/2011 7:06 PM, Daniel Kluev wrote: So I'd like to know: how do these other implementations handle concurrency matters for their primitive types, and prevent them from getting corrupted in multithreaded programs (if they do) ? I'm not only thinking about python types, but also primitive con

Re: GIL in alternative implementations

2011-05-28 Thread Steven D'Aprano
On Sat, 28 May 2011 09:39:08 -0700, John Nagle wrote: > Python allows patching code while the code is executing. Can you give an example of what you mean by this? If I have a function: def f(a, b): c = a + b d = c*3 return "hello world"*d how would I patch this function while it

Re: Beginner needs advice

2011-05-28 Thread Uncle Ben
On May 27, 5:33 pm, Ethan Furman wrote: > Lew Schwartz wrote: > > So, if I read between the lines correctly, you recommend Python 3? Does > > the windows version install with a development environment? > > Dabo, last I checked, uses wxPython, which uses wxWidgets (sp?), which > is not yet ported t

Re: Beginner needs advice

2011-05-28 Thread harrismh777
Ethan Furman wrote: Um -- how can you have on the one hand "completely not compatible" and on the other "code that can cross-execute on either version"? Great question ! .. .it has to do with education. ... if you learn 2.x (only) and attempt to program on the 3.x platform, (without helps, ed

Re: English Idiom in Unix: Directory Recursively

2011-05-28 Thread Rikishi42
On 2011-05-25, Steven D'Aprano wrote: > I know many people who have no idea what a directory is, let alone a > subdirectory, unless it's the phone directory. They're non-computer > users. Once they start using computers, they quickly work out what the > word means in context, or they ask and ge

Re: Beginner needs advice

2011-05-28 Thread Chris Angelico
On Sun, May 29, 2011 at 5:21 AM, harrismh777 wrote: > The problem is that they "look" similar.     :) C looks like every other bracey language in the world. Is that a problem? According to Wikipedia, there's quite a lot of them: http://en.wikipedia.org/wiki/List_of_programming_languages_by_categ

Re: English Idiom in Unix: Directory Recursively

2011-05-28 Thread Chris Angelico
On Sun, May 29, 2011 at 5:36 AM, Rikishi42 wrote: > Is it [the term 'incinerate'] that widespread? I figured most people > woul speak of burning. OK, my bad if it is. I think it's geographic. This list covers a lot of geography; I'm in Australia, there are quite a few Brits, and probably the bulk

Class decorators might also be super too

2011-05-28 Thread Raymond Hettinger
David Beazley wrote a class decorator blog post that is worth reading: http://dabeaz.blogspot.com/2011/05/class-decorators-might-also-be-super.html Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: bdist_wininst: install_script not run on uninstall

2011-05-28 Thread Wilbert Berendsen
Op zaterdag 28 mei 2011 schreef Mark: > This is a bug in distutils/bdist_wininst - I just created > http://bugs.python.org/issue12200 with the details and your samples, and > sadly I can't think of a work around you can use until this is fixed > (which I might get to soon, but not this weekend.

Re: English Idiom in Unix: Directory Recursively

2011-05-28 Thread GSO
The beginning of wisdom is to call things by their right names. - Chinese Proverb (So I'm told at least, I'd check with the Chinese first though ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: English Idiom in Unix: Directory Recursively

2011-05-28 Thread Chris Angelico
On Sun, May 29, 2011 at 7:25 AM, GSO wrote: > The beginning of wisdom is to call things by their right names. - Chinese > Proverb (So I'm told at least, I'd check with the Chinese first though ;) See, I thought it was "The fear of the Lord is the beginning of wisdom", but the Chinese don't worshi

Re: changing current dir and executing a shell script

2011-05-28 Thread Albert Hopkins
On Sat, 2011-05-28 at 09:41 +0200, Peter Otten wrote: > > You don't want to do this because "cd" is a built-in shell command, > and > > subprocess does not execute within a shell (by default). > > The problem is not that cd is built-in, but that there is no shell at > all. > You can change that w

Re: Beginner needs advice

2011-05-28 Thread Terry Reedy
On 5/28/2011 2:57 PM, Uncle Ben wrote: Just this past Tuesday, I blindly downloaded 3.1 and found that at the level I am workloing, all it took to get my 2.7 code to run was to put parens around the print arguments and double the slashes in integer division. I didn't even use the 2to3 automation

Re: How to catch a line with Popen

2011-05-28 Thread Nobody
On Sun, 29 May 2011 00:01:56 +0800, TheSaint wrote: > I'm looking into subprocess.Popen docs. I've launch the program with its > arguments and that's smooth. I'm expecting to read the output by > *comunicate()* at every line that prgram may blow during the process, but > the output is given only w

Re: Parse config file and command-line arguments, to get a single collection of options

2011-05-28 Thread rzed
Ben Finney wrote in news:87k4deaxfc@benfinney.id.au: > Howdy all, > > Python's standard library has modules for configuration file > parsing (configparser) and command-line argument parsing > (optparse, argparse). I want to write a program that does both, > but also: > > * Has a cascade o

portable way of sending notifying a process

2011-05-28 Thread News123
Hi, I'm looking for a portable way (windows XP / Windows Vista and Linux ) to send a signal from any python script to another one (one signa would be enough) I have several python scripts started from different parent processes occasionally some of the scripts want to tell another to reread it'

Re: How to catch a line with Popen

2011-05-28 Thread Tim Roberts
TheSaint wrote: > >I'm looking into subprocess.Popen docs. >I've launch the program with its arguments and that's smooth. I'm expecting >to read the output by *comunicate()* at every line that prgram may blow >during the process, but the output is given only when the child process is >ended. >I

float("nan") in set or as key

2011-05-28 Thread MRAB
Here's a curiosity. float("nan") can occur multiple times in a set or as a key in a dict: >>> {float("nan"), float("nan")} {nan, nan} except that sometimes it can't: >>> nan = float("nan") >>> {nan, nan} {nan} -- http://mail.python.org/mailman/listinfo/python-list

Re: float("nan") in set or as key

2011-05-28 Thread Erik Max Francis
MRAB wrote: Here's a curiosity. float("nan") can occur multiple times in a set or as a key in a dict: >>> {float("nan"), float("nan")} {nan, nan} except that sometimes it can't: >>> nan = float("nan") >>> {nan, nan} {nan} It's fundamentally because NaN is not equal to itself, by design.

Re: float("nan") in set or as key

2011-05-28 Thread Albert Hopkins
On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote: > Here's a curiosity. float("nan") can occur multiple times in a set or as > a key in a dict: > > >>> {float("nan"), float("nan")} > {nan, nan} > These two nans are not equal (they are two different nans) > except that sometimes it can't: > > >>

Re: float("nan") in set or as key

2011-05-28 Thread Tim Delaney
On 29 May 2011 10:16, Erik Max Francis wrote: > MRAB wrote: > >> Here's a curiosity. float("nan") can occur multiple times in a set or as a >> key in a dict: >> >> >>> {float("nan"), float("nan")} >> {nan, nan} >> >> except that sometimes it can't: >> >> >>> nan = float("nan") >> >>> {nan, nan

Re: float("nan") in set or as key

2011-05-28 Thread Steven D'Aprano
On Sun, 29 May 2011 00:41:16 +0100, MRAB wrote: > Here's a curiosity. float("nan") can occur multiple times in a set or as > a key in a dict: > > >>> {float("nan"), float("nan")} > {nan, nan} That's an implementation detail. Python is free to reuse the same object when you create an immutable

Re: float("nan") in set or as key

2011-05-28 Thread Chris Angelico
On Sun, May 29, 2011 at 10:28 AM, Albert Hopkins wrote: > This is the same nan, so it is equal to itself. > Actually, they're not. But it's possible the dictionary uses an 'is' check to save computation, and if one thing 'is' another, it is assumed to equal it. That's true of most well-behaved ob

Re: How to catch a line with Popen

2011-05-28 Thread Dan Stromberg
On Sat, May 28, 2011 at 4:32 PM, Tim Roberts wrote: > TheSaint wrote: > > > >I'm looking into subprocess.Popen docs. > >I've launch the program with its arguments and that's smooth. I'm > expecting > >to read the output by *comunicate()* at every line that prgram may blow > >during the process,

Re: float("nan") in set or as key

2011-05-28 Thread Erik Max Francis
Albert Hopkins wrote: On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote: 1.0 == 1.0 True float("nan") == float("nan") False I can't cite this in a spec, but it makes sense (to me) that two things which are nan are not necessarily the same nan. It's part of the IEEE standard. -- Erik Max Franc

Re: The worth of comments

2011-05-28 Thread Gregory Ewing
Irmen de Jong wrote: I don't see how that is opposed to what Grant was saying. It's that these 'contracts' tend to change and that people forget or are too lazy to update the comments to reflect those changes. However, I can't see that deleting the comment documenting the contract can be the

Re: English Idiom in Unix: Directory Recursively

2011-05-28 Thread Steven D'Aprano
On Sun, 29 May 2011 05:58:01 +1000, Chris Angelico wrote: > Geeks tend to have larger vocabularies than non-geeks, on average; > probably akin to our love of word games and precision (two distinct > notions that bridge surprisingly often). And also because more educated people in general tend to

Re: float("nan") in set or as key

2011-05-28 Thread Gregory Ewing
MRAB wrote: float("nan") can occur multiple times in a set or as a key in a dict: >>> {float("nan"), float("nan")} {nan, nan} except that sometimes it can't: >>> nan = float("nan") >>> {nan, nan} {nan} NaNs are weird. They're not equal to themselves: Python 2.7 (r27:82500, Oct 15 2010,

Re: The worth of comments

2011-05-28 Thread Ben Finney
Gregory Ewing writes: > If the contract comment doesn't match what code does, then there are > two possibilities -- the comment is wrong, or the code is wrong. The > appropriate response is to find out which one is wrong and fix it. You omit the common third possibility: *both* the comment and t

Re: The worth of comments

2011-05-28 Thread Irmen de Jong
On 29-5-2011 2:47, Gregory Ewing wrote: > Irmen de Jong wrote: > >> I don't see how that is opposed to what Grant was saying. It's that these >> 'contracts' >> tend to change and that people forget or are too lazy to update the comments >> to reflect >> those changes. > > However, I can't see t

Re: Beginner needs advice

2011-05-28 Thread harrismh777
Chris Angelico wrote: Both versions of Python are the same language, because they "think" the same way; I appreciate your thought. And there is an obvious continuity in philosophy between 2.x and 3.x; in fact even a cursory study of the history of python demonstrates a concerted effort t

Re: Beginner needs advice

2011-05-28 Thread Chris Angelico
On Sun, May 29, 2011 at 12:02 PM, harrismh777 wrote: > Chris Angelico wrote: >> Both versions of Python are >> the same language, because they "think" the same way; >     I see your point. But, knowing that 3.x "thinks" like 2.x is not helpful > when we all know that languages don't think, people

Re: float("nan") in set or as key

2011-05-28 Thread Grant Edwards
On 2011-05-29, Albert Hopkins wrote: > On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote: >> Here's a curiosity. float("nan") can occur multiple times in a set or as >> a key in a dict: >> >> >>> {float("nan"), float("nan")} >> {nan, nan} >> > These two nans are not equal (they are two different n

Re: Beginner needs advice

2011-05-28 Thread harrismh777
Steven D'Aprano wrote: A straw man is not when somebody points out holes in your argument, or unwanted implications that you didn't realise were there. It is when somebody makes claims on your behalf that you did not make to discredit you, not because you don't understand the implications of your

Re: Beginner needs advice

2011-05-28 Thread Dotan Cohen
On Fri, May 27, 2011 at 23:40, harrismh777 wrote: > You have erected a straw-man... once again. > I think that is a red herring, not a strawman. > Most 2.x code *will not* run correctly in 3.x/  Most of the best > improvements and enhancements of 3.x will not back-port to below 2.7, and > almost

Re: float("nan") in set or as key

2011-05-28 Thread John Nagle
On 5/28/2011 6:04 PM, Gregory Ewing wrote: MRAB wrote: float("nan") can occur multiple times in a set or as a key in a dict: >>> {float("nan"), float("nan")} {nan, nan} except that sometimes it can't: >>> nan = float("nan") >>> {nan, nan} {nan} NaNs are weird. They're not equal to themselve

Re: Class decorators might also be super too

2011-05-28 Thread Michele Simionato
He is basically showing that using mixins for implementing logging is not such a good idea, i.e. you can get the same effect in a better way by making use of other Python features. I argued the same thing many times in the past. I even wrote a module once (strait) to reimplement 99% of multiple