The Artima Developer Community
Sponsored Link

Python Buzz Forum
path module

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
path module Posted: Jan 24, 2004 7:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: path module
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

I've been using Jason Jorendorff's path module lately in a couple command-line scripts. A while ago I stopped writing many scripts in shell, since I always found it hard to grow the scripts, and the quoting always causes problems. How many shell scripts can deal with filenames with spaces in them? Shell scripting is a crappy language. I always thought Tcl would make a good shell -- both simpler and more reliable than shell, but just as string-oriented. But it never seemed to happen... so it goes.

Anyway, when writing command-line programs you do lots of file operations, and typically use os.path a lot. os.path is a pain to use -- too much os.path.join(os.path.dirname(...)) and the like. This makes Python rather painful to use.

Despite wanting a path module for a long time, I keep forgetting to use the one I have (standard or no). After using it some, I find it very pleasant. Besides avoiding os.path, I get nice functions like text() and write_text() which read and write text to the file in a single chunk, no open() required. And I'm sure there's more good stuff in there that I haven't assimilated yet either.

There's an outstanding (pre) PEP, and a second discussion on comp.lang.python surrounding a path module. Personally Jason's module fits me well, and I think it's worth the time to learn even if you've become accustomed (as I have) to os.path.

(And I like the use of / for os.path.join -- purists say that it's not division, but I say who cares; % substitution isn't modulo either)

Read: path module

Topic: Checkstyle or PMD? Previous Topic   Next Topic Topic: J2EE done right

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use