On Sun, Jun 19, 2011 at 11:00 PM, Tim Hanson <tjhan...@yahoo.com> wrote: > Using linux and Python 2.6, learning how to work with files from a Windows > oriented textbook: > > This works: > infile=open('/foo/bar/prog/py_modules/this_is_a_test','r') > > This doesn't: > infile=open('~/prog/py_modules/this_is_a_test','r') > > Can't I work with files using Unix expressions?
As Dennis explained, no. At least, not directly. Python doesn't run filepaths through the shell for expansion. However, you can use os.path.expanduser() to make ~-paths work: http://docs.python.org/library/os.path.html#os.path.expanduser Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list