[Tutor] glob is driving me berserk [os.path.join]

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Mar 30 18:54:27 EST 2004

On Tue, 30 Mar 2004, Shawhan, Doug (EM, ITS) wrote:

> I am officially going insane. Really. I am sitting in a corner picking
> my nails and singing "que sera sera.".
> This worked.
> May the lord smile on me and put me to work on an os that does not
> require such a skull-melting gymkhana to SIMPLY READ A PATH
> *&^*^%$&^%&%&%$!!!!!

Hi Doug,

Yeah, this is something that really should not be so difficult.  Had
people really thought things through, we'd never run into such a silly
issue.  *sigh*

What you ran into is an intersection of our use, as programmers, of the
backslash character to increase the number of characters we can type
directly from the keyboard.  This conflicts slightly with the use of the
literal backslash character as the path separator on the Windows platform.
So we have to be a bit careful about paths.

But by the way: using os.path.join() and the other os.path functions may
help to avoid these kinds of silly issues:


On a Unix system, here's a sample of what os.path can do:

>>> os.path.expanduser(os.path.join("~dyoo", "public_html"))

You may want to see if os.path will be useful for you, as it's a better
platform-independent way of building paths reliably, so that you should
hopefully not have to worry about backslashes so much.

Good luck!

More information about the Tutor mailing list