On Mon, 2011-06-20 at 08:14 +0200, Florencio Cano wrote:
> > 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?
> 
> You can use the glob module:
> http://docs.python.org/library/glob.html#module-glob

Regardless of the module that you use, you should also be using
os.path.join() to create paths. I never rely on hard coded paths
(especially since most of my code needs to run on multiple OS). In the
above example, you can easily put together a fairly complex path as
well, using os.path.join('foo', 'bar', 'prog', 'py_modules', ... ) which
will take care of what you need.

Not sure about regular python, but certainly in the wx GUI toolkit,
there is a wx.StandardPaths.Get() function which will get the user's
home or standard path where you can store all sorts of config data etc
in a hidden directory as well.

-- 
-- Paul

http://www.paulscott.za.net
http://twitter.com/paulscott56
http://www.chisimba.com

Attachment: signature.asc
Description: This is a digitally signed message part

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to