Re: Can I get a technical explanation on the following error

2009-05-24 Thread Jim Garrison
And as an interesting exercise, try print r'test \' print r'test \\' Because of the way raw string parsing is defined, neither of these will pass the parser. In fact, a raw string cannot have a backslash as its last character. -- http://mail.python.org/mailman/listinfo/python-list

Python 3.0 online docs broken

2009-04-08 Thread Jim Garrison
Jim Garrison wrote: Ye Liu wrote: On Apr 6, 6:33 pm, Jim Garrison wrote: I notice the online docs (at docs.python.org/3.0/index.html) were updated today. It seems some of the top-level pages, like Tutorial, "Using Python", "Language Reference" are truncated after the

Re: New online docs broken?

2009-04-07 Thread Jim Garrison
Ye Liu wrote: On Apr 6, 6:33 pm, Jim Garrison wrote: I notice the online docs (at docs.python.org/3.0/index.html) were updated today. It seems some of the top-level pages, like Tutorial, "Using Python", "Language Reference" are truncated after the first few paragraphs.

New online docs broken?

2009-04-06 Thread Jim Garrison
I notice the online docs (at docs.python.org/3.0/index.html) were updated today. It seems some of the top-level pages, like Tutorial, "Using Python", "Language Reference" are truncated after the first few paragraphs. -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax disagreement between IDLE and pydev?

2009-03-30 Thread Jim Garrison
Jim Garrison wrote: IDLE (3.1a1) accepts a,*b = re.split(str,pattern) and does the right thing ('a' gets the first result and 'b' gets the rest). pydev configured to use the exact same Python 3.1a1 runtime doesn't like this syntax (in my source, column 23 is th

Syntax disagreement between IDLE and pydev?

2009-03-30 Thread Jim Garrison
IDLE (3.1a1) accepts a,*b = re.split(str,pattern) and does the right thing ('a' gets the first result and 'b' gets the rest). pydev configured to use the exact same Python 3.1a1 runtime doesn't like this syntax (in my source, column 23 is the asterisk): Encountered "*" at line 32, colu

Re: pickle.load() extremely slow performance

2009-03-23 Thread Jim Garrison
Steve Holden wrote: Jean-Paul Calderone wrote: On Mon, 23 Mar 2009 10:57:54 -0500, Jim Garrison wrote: Benjamin Peterson wrote: Terry Reedy udel.edu> writes: 3.1a1 is out and I believe it has the io improvements. Massive ones, too. It'd be interesting to see your results on the al

Re: pickle.load() extremely slow performance

2009-03-23 Thread Jim Garrison
Benjamin Peterson wrote: Terry Reedy udel.edu> writes: 3.1a1 is out and I believe it has the io improvements. Massive ones, too. It'd be interesting to see your results on the alpha. On 3.1a1 the unpickle step takes 2.4 seconds, an 1875% improvement. Thanks. -- http://mail.python.org/mailm

Re: pickle.load() extremely slow performance

2009-03-20 Thread Jim Garrison
Jim Garrison wrote: > John Machin wrote: [snip] >> Have you considered using cPickle instead of pickle? >> Have you considered using *ickle.dump(..., protocol=-1) ? > > I'm using Python 3 on Windows (Server 2003). According to the docs > >"The pickl

Re: pickle.load() extremely slow performance

2009-03-20 Thread Jim Garrison
John Machin wrote: > On Mar 21, 9:25 am, Jim Garrison wrote: >> I'm converting a Perl system to Python, and have run into a severe >> performance problem with pickle. >> >> One facet of the system involves scanning and loading into memory a >> couple of para

pickle.load() extremely slow performance

2009-03-20 Thread Jim Garrison
I'm converting a Perl system to Python, and have run into a severe performance problem with pickle. One facet of the system involves scanning and loading into memory a couple of parallel directory trees containing OTO 10^4 files. The trees don't change during development/testing and the scan tak

Missing values in tuple assignment

2009-03-19 Thread Jim Garrison
Use case: parsing a simple config file line where lines start with a keyword and have optional arguments. I want to extract the keyword and then pass the rest of the line to a function to process it. An obvious use of split(None,1) cmd,args= = line.split(None,1); if cmd in self.switch: s

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Jim Garrison
S Arrowsmith wrote: Jim Garrison wrote: It's a shame the iter(o,sentinel) builtin does the comparison itself, instead of being defined as iter(callable,callable) where the second argument implements the termination test and returns a boolean. This would seem to add much more generality.

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Jim Garrison
Andrii V. Mishkovskyi wrote: Just before you start writing a PEP, take a look at `takewhile' function in `itertools' module. ;) OK, after reading the itertools docs I'm not sure how to use it in this context. takewhile() requires a sequence, and turning f.read(bufsize) into an iterable require

Re: How to do this in Python? - A "gotcha"

2009-03-18 Thread Jim Garrison
Jim Garrison wrote: Luis Zarrabeitia wrote: On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: with open(filename, "rb") as f: for buf in iter(lambda: f.read(1000),''): do_something(buf) This is the most pythonic solution yet. Thanks to all the respond

Re: How to do this in Python?

2009-03-18 Thread Jim Garrison
Luis Zarrabeitia wrote: On Tuesday 17 March 2009 06:04:36 pm Jim Garrison wrote: with open(filename, "rb") as f: for buf in iter(lambda: f.read(1000),''): do_something(buff) This is the most pythonic solution yet. Thanks to all the responders who took time to p

Re: How to do this in Python?

2009-03-17 Thread Jim Garrison
andrew cooke wrote: > Jim Garrison wrote: >> I'm an experienced C/Java/Perl developer learning Python. >> >> What's the canonical Python way of implementing this pseudocode? [snip] > > embarrassed by the other reply i have read, There's always some &q

Re: How to do this in Python?

2009-03-17 Thread Jim Garrison
Tim Chase wrote: >> Am I missing something basic, or is this the canonical way: >> >> with open(filename,"rb") as f: >> buf = f.read(1) >> while len(buf) > 0 >> # do something >> buf = f.read(1) > > That will certainly do. Since read()

How to do this in Python?

2009-03-17 Thread Jim Garrison
I'm an experienced C/Java/Perl developer learning Python. What's the canonical Python way of implementing this pseudocode? String buf File f while ((buf=f.read(1)).length() > 0) { do something } In other words, I want to read a potentially large file in 100

Re: Raw String Question

2009-03-12 Thread Jim Garrison
Tim Chase wrote: >>> r"a\" SyntaxError: EOL while scanning string literal (, line 1) It seems the parser is interpreting the backslash as an escape character in a raw string if the backslash is the last character. Is this expected? Yep...as documented[1], "even a raw string cannot end in a

Re: Raw String Question

2009-03-12 Thread Jim Garrison
Tim Chase wrote: >>> r"a\" SyntaxError: EOL while scanning string literal (, line 1) It seems the parser is interpreting the backslash as an escape character in a raw string if the backslash is the last character. Is this expected? Yep...as documented[1], "even a raw string cannot end in a

Raw String Question

2009-03-12 Thread Jim Garrison
I'm an experienced Perl developer learning Python, but I seem to be missing something about raw strings. Here's a transcript of a Python shell session: Python 3.0 (r30:67507, Dec 3 2008, 20:14:27) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more infor