On Fri, Mar 18, 2011 at 4:00 PM, Ethan Furman <et...@stoneleaf.us> wrote:
> Dan Stromberg wrote: > >> >> Are you on windows? >> >> You probably should use / as your directory separator in Python, not \. >> In Python, and most other programming languages, \ starts an escape >> sequence, so to introduce a literal \, you either need to prefix your string >> with r (r"\foo\bar") or double your backslashes ("\\foo\\bar"). >> >> / works fine on windows, and doesn't require escaping ("/foo/bar"). >> > > Depends on your definition of 'fine'. > > --> from glob import glob > --> from pprint import pprint as pp > --> pp(glob('c:/temp/*.pdf')) > ['c:/temp\\choose_python.pdf', > 'c:/temp\\COA.pdf', > 'c:/temp\\job_setup.pdf'] > > Visually ugly, and a pain to compare files and paths. > I argue that the first is quite a bit more readable than the second: 'c:/temp/choose_python.pdf' os.path.join([ 'c:', 'temp', 'choose_python.pdf' ]) Also, heard of os.path.normpath? You probably shouldn't compare pathnames without it.
-- http://mail.python.org/mailman/listinfo/python-list