[issue21539] pathlib's Path.mkdir() should allow for mkdir -p functionality

2014-05-19 Thread Jim Garrison
New submission from Jim Garrison: As of Python 3.2, `os.makedirs()` takes `exist_ok` as a keyword argument. If set to true, the function does not raise an error if the directory already exists. This makes the function's behavior similar to `mkdir -p` on the UNIX commandline. (See https

[issue4147] xml.dom.minidom toprettyxml: omit whitespace for text-only elements

2009-07-16 Thread Jim Garrison
Jim Garrison jgarri...@troux.com added the comment: To clarify: ... it should never alter the content of (i.e. insert whitespace into) existing text elements that contain non-whitespace characters. -- ___ Python tracker rep...@bugs.python.org http

[issue4147] xml.dom.minidom toprettyxml: omit whitespace for text-only elements

2009-07-15 Thread Jim Garrison
Jim Garrison jgarri...@troux.com added the comment: Also needed here. While pretty-printing should be able to insert non-significant whitespace BETWEEN xml elements, it should never alter the content of (i.e. insert whitespace into) existing text elements. -- nosy: +jgarrison

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

2009-05-25 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 j...@acm.org 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

Re: New online docs broken?

2009-04-07 Thread Jim Garrison
Ye Liu wrote: On Apr 6, 6:33 pm, Jim Garrison j...@acm.org 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. Yea, same

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

[issue5674] distutils fails to find Linux libs (lib.....so.n)

2009-04-02 Thread Jim Garrison
New submission from Jim Garrison jgarri...@troux.com: Trying to build 3.1a1 on Fedora 9, the following extensions get skipped even though the requisite packages are installed _dbm _gdbm _hashlib _sqlite3 _ssl bz2

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,

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 the asterisk): Encountered

Re: pickle.load() extremely slow performance

2009-03-23 Thread Jim Garrison
Benjamin Peterson wrote: Terry Reedy tjreedy at 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. --

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 j...@acm.org wrote: Benjamin Peterson wrote: Terry Reedy tjreedy at 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

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

Re: pickle.load() extremely slow performance

2009-03-20 Thread Jim Garrison
John Machin wrote: On Mar 21, 9:25 am, Jim Garrison j...@acm.org 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 parallel directory trees containing OTO 10

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 pickle module has an transparent optimizer (_pickle

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:

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 ponder this seemingly

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 responders who took time

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

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

2009-03-18 Thread Jim Garrison
S Arrowsmith wrote: Jim Garrison j...@acm.org 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

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

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() should simply

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 trollish behavior in any comp.lang.* group. Too many

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

Re: Raw String Question

2009-03-12 Thread Jim Garrison
Tim Chase wrote: ra\ SyntaxError: EOL while scanning string literal (pyshell#45, 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

Re: Raw String Question

2009-03-12 Thread Jim Garrison
Tim Chase wrote: ra\ SyntaxError: EOL while scanning string literal (pyshell#45, 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