Re: Suggest some exercises on Python

2011-04-05 Thread harrismh777
neil harper wrote: I'm a new bie. I have just started learning Python (3.0), finished with official tutorial. I would like to have your opinion on some Opinions around here are pretty much like elbows and knee caps... everybody has them, and yours are really the only ones that matter to

Re: is python 3 better than python 2?

2011-04-05 Thread Dan Stromberg
On Tue, Apr 5, 2011 at 10:04 PM, Terry Reedy wrote: > On 4/5/2011 4:42 PM, John Nagle wrote: > > Well, actually Unicode support went in back around Python 2.4. >> > > Even earlier, I think, but there were and still are problems with unicode > in 2.x. Some were and will only be fixed in 3.x. > >

Re: is python 3 better than python 2?

2011-04-05 Thread Terry Reedy
On 4/5/2011 4:42 PM, John Nagle wrote: Well, actually Unicode support went in back around Python 2.4. Even earlier, I think, but there were and still are problems with unicode in 2.x. Some were and will only be fixed in 3.x. In 3.x, ASCII strings went away, but that was more of a removal.

How to debug c libraries on python?

2011-04-05 Thread yuan zheng
Hi, everyone: I encouter a problem: I invoke some c libraries in python through the api "CDLL".Possibly, there is sth. wrong in my c libraries. It would appear segment fault when executing some func in c libraries which invoked through "CDLL". How can I debug? I attempted to debug it with

Re: Python benefits over Cobra

2011-04-05 Thread Brendan Simon
> On 05-Apr-11 06:22 AM, Brendan Simon (eTRIX) wrote: >> >> Any other arguments where Python has benefits over Cobra ?? >> >> Cheers, Brendan. >> > Two questions: > 1. Is Cobra Open Source? > 2. The blog ended on October, did he run out of steam? > > I liked the '.', in place of '.s

Re: Fun python 3.2 one-liner

2011-04-05 Thread Ben Finney
Raymond Hettinger writes: > On Apr 5, 6:38 am, Daniel Fetchinson > wrote: > > Yeah, but we don't live in the 80's or 90's anymore and our screens > > can support xterms (or let alone IDE widows) much wider than 80 > > characters. I'm using 140 for python these days. Seriously, who > > would want

Re: Standard config file format

2011-04-05 Thread Chris Rebert
On Tue, Apr 5, 2011 at 7:16 PM, Vincent Davis wrote: > I am working on a program to monitor directory file changes and am would > like a configuration file. This file would specify email addresses, file and > directory locations.. Is there a preferred format to use with python? ConfigParser s

Standard config file format

2011-04-05 Thread Vincent Davis
I am working on a program to monitor directory file changes and am would like a configuration file. This file would specify email addresses, file and directory locations.. Is there a preferred format to use with python? -- Thanks Vincent Davis -- http://mail.python.org/mailman/listinfo/python

Sandboxed Python: memory limits?

2011-04-05 Thread Chris Angelico
Is it possible, and if so is it easy, to limit the amount of memory an embedded Python interpreter is allowed to allocate? I don't want to ulimit/rlimit the process if I don't have to (or rather, I want the process's limit to be high, and the Python limit much lower), but just to force Python to th

Re: How to program in Python to run system commands in 1000s of servers

2011-04-05 Thread Roy Smith
In article , geremy condra wrote: > On Tue, Apr 5, 2011 at 7:51 AM, Babu wrote: > > > > Here is my problem:  Want to program in python to run sysadmin > > commands across 1000s of servers and gather the result in one place. > > Many times the commands need to be run as root.  We cannot use ssh

Re: 3D subfigures in matplotlib?

2011-04-05 Thread eryksun ()
On Tuesday, April 5, 2011 6:17:34 AM UTC-4, MATLABdude wrote: > How can I make maybe 3D subfigures with Python and matplotlib? > > I found the following example (http://matplotlib.sourceforge.net/ > examples/mplot3d/subplot3d_demo.html), but it doesn't work. > > [snip] > > I am using Python 2.6.6

Re: Fun python 3.2 one-liner

2011-04-05 Thread Raymond Hettinger
On Apr 5, 6:38 am, Daniel Fetchinson wrote: > >> what is the character limit on a one liner :P. > > > For PEP 8 compliance, 80 characters. :-) > > Yeah, but we don't live in the 80's or 90's anymore and our screens > can support xterms (or let alone IDE widows) much wider than 80 > characters. I'm

Re: a better way to invert a list?

2011-04-05 Thread Raymond Hettinger
[Ian Kelly] > Which is O(n).  If that is too verbose, you could also use a dictionary: > > def invert(p): >     return dict(map(reversed, enumerate(p))) def inv(p): return dict(zip(p, itertools.count())) Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: a better way to invert a list?

2011-04-05 Thread scattered
On Apr 5, 5:46 pm, Ian Kelly wrote: > On Tue, Apr 5, 2011 at 3:17 PM, scattered wrote: > > Greetings, > > > I've been playing around (in Python 3.1) with permutations of > > 0,1,...,n-1, represented by lists, p, of length n, where p[i] = the > > image of i under the permutation. I wanted to be ab

Re: replace regex in file using a dictionary

2011-04-05 Thread Martin De Kauwe
yes thanks both work nicely, I will ponder the suggestions. -- http://mail.python.org/mailman/listinfo/python-list

Re: a better way to invert a list?

2011-04-05 Thread Ian Kelly
On Tue, Apr 5, 2011 at 3:17 PM, scattered wrote: > Greetings, > > I've been playing around (in Python 3.1) with permutations of > 0,1,...,n-1, represented by lists, p, of length n, where p[i] = the > image of i under the permutation. I wanted to be able to calculate the > inverse of such a permuta

a better way to invert a list?

2011-04-05 Thread scattered
Greetings, I've been playing around (in Python 3.1) with permutations of 0,1,...,n-1, represented by lists, p, of length n, where p[i] = the image of i under the permutation. I wanted to be able to calculate the inverse of such a permutation, and came up with the following succint but not quite re

Re: is python 3 better than python 2?

2011-04-05 Thread John Nagle
On 4/5/2011 7:46 AM, Mel wrote: neil wrote: what are the advantages? if it wasn't for python 3 breaking backwards compatibility would it be the better choice? IMHO the killer app for Python 3 is in more reasonable support for foreign character sets (no matter where your are, at least one out

Re: Suggest some exercises on Python

2011-04-05 Thread Blockheads Oi Oi
On 05/04/2011 18:24, Steven D'Aprano wrote: On Tue, 05 Apr 2011 13:18:19 -0400, Terry Reedy wrote: On 4/5/2011 9:13 AM, Jins Thomas wrote: I'm a new bie. I have just started learning Python (3.0), Please download, install, and use 3.2. To elaborate further: Python 3.0 is not supported, an

Indentation levels and line lengths (was Re: Fun python 3.2 one-liner)

2011-04-05 Thread Chris Angelico
On Wed, Apr 6, 2011 at 3:48 AM, Steven D'Aprano wrote: >> and has on occasion gone as far as 12-16. > > I would consider anything more than four indents a code smell. That is, > four is unexceptional; five would make me look over the code to see if it > could be refactored; six would make me look

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-05 Thread Philip Semanchuk
On Apr 5, 2011, at 12:58 PM, John Ladasky wrote: > Hi Philip, > > Thanks for the reply. > > On Apr 4, 4:34 pm, Philip Semanchuk wrote: >> So if you're going to use multiprocessing, you're going to use pickle, and >> you >> need pickleable objects. > > OK, that's good to know. But as Dan Str

Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
what is the character limit on a one liner :P. >>> >>> For PEP 8 compliance, 80 characters. :-) >> >> Yeah, but we don't live in the 80's or 90's anymore and our screens can >> support xterms (or let alone IDE widows) much wider than 80 characters. >> I'm using 140 for python these days. Serio

Re: Fun python 3.2 one-liner

2011-04-05 Thread Steven D'Aprano
On Wed, 06 Apr 2011 01:19:06 +1000, Chris Angelico wrote: > On Wed, Apr 6, 2011 at 1:07 AM, Steven D'Aprano > wrote: >> On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: >> >>> Seriously, who would want to limit >>> him/herself to 80 characters in 2011? >> >> Seriously, or is that a rh

Re: Suggest some exercises on Python

2011-04-05 Thread geremy condra
On Tue, Apr 5, 2011 at 6:13 AM, Jins Thomas wrote: > Hi all, > > I'm a new bie. I have just started learning Python (3.0), finished with > official tutorial. I would like to have your opinion on some > > 1. Good books (for an intermediate in programming) with lot's of exercise i > can try it out.

Re: Light weight IDE like pywin for os x 10.6

2011-04-05 Thread Detlev Offenbach
python wrote: > I have looked a while for this answer. Sorry if it right before me. > > I have move from Windows to os x. The thing I miss most is pywin. > I know you can purchase or download full IDE's for python or even use > Eclipse. I really liked the ability to switch from interactive >

Re: Suggest some exercises on Python

2011-04-05 Thread Steven D'Aprano
On Tue, 05 Apr 2011 13:18:19 -0400, Terry Reedy wrote: > On 4/5/2011 9:13 AM, Jins Thomas wrote: > >> I'm a new bie. I have just started learning Python (3.0), > > Please download, install, and use 3.2. To elaborate further: Python 3.0 is not supported, and is buggy and slow. You should avoid

Re: Suggest some exercises on Python

2011-04-05 Thread Terry Reedy
On 4/5/2011 9:13 AM, Jins Thomas wrote: I'm a new bie. I have just started learning Python (3.0), Please download, install, and use 3.2. finished with official tutorial. > I would like to have your opinion on some 1. Good books (for an intermediate in programming) with lot's of ... 2. O

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-05 Thread John Ladasky
Hi Philip, Thanks for the reply. On Apr 4, 4:34 pm, Philip Semanchuk wrote: > So if you're going to use multiprocessing, you're going to use pickle, and you > need pickleable objects. OK, that's good to know. > > Pickling is still a pretty > > vague progress to me, but I can see that you have

Re: How to program in Python to run system commands in 1000s of servers

2011-04-05 Thread geremy condra
On Tue, Apr 5, 2011 at 7:51 AM, Babu wrote: > > Here is my problem:  Want to program in python to run sysadmin > commands across 1000s of servers and gather the result in one place. > Many times the commands need to be run as root.  We cannot use ssh as > root remote connectivity as well.  What ar

Re: is python 3 better than python 2?

2011-04-05 Thread Gnarlodious
On Apr 5, 6:42 am, neil wrote: > what are the advantages? if it wasn't for python 3 breaking backwards > compatibility would it be the better choice? I adopted Py3 because of support of OrderedDict and many new features. Since mine was a new project using no existing libraries, it made sense. --

Re: is python 3 better than python 2?

2011-04-05 Thread Terry Reedy
On 4/5/2011 8:42 AM, neil wrote: what are the advantages? Py3 complete many transitions begun in Py2. In some cases, that means deleting old obsolete stuff, such as old-style classes. if it wasn't for python 3 breaking backwards compatibility would it be the better choice? Assuming equal

Re: Multiprocessing, shared memory vs. pickled copies

2011-04-05 Thread Robert Kern
On 4/4/11 7:05 PM, Robert Kern wrote: On 4/4/11 3:20 PM, John Ladasky wrote: However, at least in Python 2.7, multiprocessing seems to have a C extension module defining the Connection objects. Unfortunately, it looks like this C extension just imports the regular pickler that is not aware of

Re: replace regex in file using a dictionary

2011-04-05 Thread nn
On Apr 5, 3:59 am, Martin De Kauwe wrote: > Hi, > > So i want to replace multiple lines in a text file and I have reasoned > the best way to do this is with a dictionary. I have simplified my > example and broadly I get what I want however I am now printing my > replacement string and part of the

Re: Fun python 3.2 one-liner

2011-04-05 Thread Tim Wintle
On Tue, 2011-04-05 at 15:38 +0200, Daniel Fetchinson wrote: > Yeah, but we don't live in the 80's or 90's anymore and our screens > can support xterms (or let alone IDE widows) much wider than 80 > characters. I'm using 140 for python these days. Seriously, who would > want to limit him/herself to

Re: Fun python 3.2 one-liner

2011-04-05 Thread Chris Angelico
On Wed, Apr 6, 2011 at 1:07 AM, Steven D'Aprano wrote: > On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: > >> Seriously, who would want to limit >> him/herself to 80 characters in 2011? > > Seriously, or is that a rhetorical question? > > People who like to have two source files side-

Re: Suggest some exercises on Python

2011-04-05 Thread neil harper
On Tue, 2011-04-05 at 18:43 +0530, Jins Thomas wrote: > Hi all, > > I'm a new bie. I have just started learning Python (3.0), finished > with official tutorial. I would like to have your opinion on some > > 1. Good books (for an intermediate in programming) with lot's of > exercise i can try it

Re: Fun python 3.2 one-liner

2011-04-05 Thread Steven D'Aprano
On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: >>> what is the character limit on a one liner :P. >> >> For PEP 8 compliance, 80 characters. :-) > > Yeah, but we don't live in the 80's or 90's anymore and our screens can > support xterms (or let alone IDE widows) much wider than 80

How to program in Python to run system commands in 1000s of servers

2011-04-05 Thread Babu
Here is my problem: Want to program in python to run sysadmin commands across 1000s of servers and gather the result in one place. Many times the commands need to be run as root. We cannot use ssh as root remote connectivity as well. What are the different ways of programming in python to achie

Re: is python 3 better than python 2?

2011-04-05 Thread Mel
neil wrote: > what are the advantages? if it wasn't for python 3 breaking backwards > compatibility would it be the better choice? IMHO the killer app for Python 3 is in more reasonable support for foreign character sets (no matter where your are, at least one out of the hundred-odd Unicode char

Re: running Python2 Python3 parallel concurrent

2011-04-05 Thread harrismh777
rusi wrote: Not sure if this is relevant... python-mode (emacs mode for python development) is broken for python 3 I submitted a 1-line patch which makes python-mode work for 2.x and 3.x Its relevant to Mac OSX, but not so much for what I'm doing in Linux, here. On the other hand, I can't see

Re: proposal to allow to set the delimiter in str.format to something other than curly bracket

2011-04-05 Thread Neil Cerutti
On 2011-04-04, Alia Khouri wrote: > Nice! I didn't think of that. I guess I could get some > additional performance by taking the re.compile step out of the > function. Thanks for the tip! I recommend "The Pragmatic Programmer," (Hunt, Thomas) ISBN 978-0201616224 and "The Practice of Programming,

Re: Fun python 3.2 one-liner

2011-04-05 Thread Daniel Fetchinson
>> what is the character limit on a one liner :P. > > For PEP 8 compliance, 80 characters. :-) Yeah, but we don't live in the 80's or 90's anymore and our screens can support xterms (or let alone IDE widows) much wider than 80 characters. I'm using 140 for python these days. Seriously, who would w

Suggest some exercises on Python

2011-04-05 Thread Jins Thomas
Hi all, I'm a new bie. I have just started learning Python (3.0), finished with official tutorial. I would like to have your opinion on some 1. Good books (for an intermediate in programming) with lot's of exercise i can try it out. For example when i started with Perl i was going through a book

Re: Python benefits over Cobra

2011-04-05 Thread Boris FELD
Cobra seems interessant, open-source, but the dependance on Mono and .Net annoy me a bit. Otherwise, cobra have good ideas, a syntax similar to python. One thing i really love is the "How-To" and the "Samples" pages on it's website, i think it's a very good thing for beginners. FELD Boris 2011/

python fighting game?(like street fighter)

2011-04-05 Thread neil harper
are there any good fighting games in the style of street fighter or guilty gear? -- http://mail.python.org/mailman/listinfo/python-list

is python 3 better than python 2?

2011-04-05 Thread neil
what are the advantages? if it wasn't for python 3 breaking backwards compatibility would it be the better choice? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python benefits over Cobra

2011-04-05 Thread Colin J. Williams
On 05-Apr-11 06:22 AM, Brendan Simon (eTRIX) wrote: I just came across the Cobra language, which appears to be heavily influenced by Python (and other languages). The pitch sounds great. It's supposed to have: 1. Quick, expressive coding 2. Fast execution 3. Static and dynamic binding

Python benefits over Cobra

2011-04-05 Thread Brendan Simon (eTRIX)
I just came across the Cobra language, which appears to be heavily influenced by Python (and other languages). The pitch sounds great. It's supposed to have: 1. Quick, expressive coding 2. Fast execution 3. Static and dynamic binding 4. Language level support for quality http:/

Re: replace regex in file using a dictionary

2011-04-05 Thread Yashwin Kanchan
How about creating a new string instead of replacing the original. def replace_keys(text, replacements_dict): text_list = text.split('\n') new_text = '' for line in text_list: key=line.split('=')[0] if key.strip() in replacements_dict: new_text = new_text +

3D subfigures in matplotlib?

2011-04-05 Thread MATLABdude
How can I make maybe 3D subfigures with Python and matplotlib? I found the following example (http://matplotlib.sourceforge.net/ examples/mplot3d/subplot3d_demo.html), but it doesn't work. --- from mpl_toolkits.mplot3d.axes3d import Axes3D import matplotlib.pyplot as plt # imports specific to th

Re: replace regex in file using a dictionary

2011-04-05 Thread Vlastimil Brom
2011/4/5 Martin De Kauwe : > Hi, > > So i want to replace multiple lines in a text file and I have reasoned > the best way to do this is with a dictionary. I have simplified my > example and broadly I get what I want however I am now printing my > replacement string and part of the original express

Re: XML header with lxml

2011-04-05 Thread Stefan Behnel
Chroma Key, 04.04.2011 21:49: On 2011-04-04 18:54:40 +0200, Jabba Laci said: I want to construct an XML file with lxml but I don't find how to add the '' header. from lxml import etree as ET html = ET.Element("html") print ET.tostring(html) Add the "xml_declaration=True" as an argument of e

Re: XML header with lxml

2011-04-05 Thread Stefan Behnel
Jabba Laci, 04.04.2011 18:54: I want to construct an XML file with lxml but I don't find how to add the '' header. This is not required. According to the XML spec, the default is: So, unless you diverge from these values, you do not need an XML declaration in your file. If you want to out

replace regex in file using a dictionary

2011-04-05 Thread Martin De Kauwe
Hi, So i want to replace multiple lines in a text file and I have reasoned the best way to do this is with a dictionary. I have simplified my example and broadly I get what I want however I am now printing my replacement string and part of the original expression. I am guessing that I will need to

Re: Testing for performance regressions

2011-04-05 Thread geremy condra
On Mon, Apr 4, 2011 at 10:25 PM, Steven D'Aprano wrote: > On Mon, 04 Apr 2011 20:59:52 -0700, geremy condra wrote: > >> On Mon, Apr 4, 2011 at 7:45 PM, Steven D'Aprano >> wrote: > >>> * The disclaimers about timing code snippets that can be found in the >>> timeit module apply. If possible, use t