Re: Obtain the file's path.

2019-09-18 Thread Cameron Simpson
On 18Sep2019 03:36, eryk sun wrote: On 9/17/19, Cameron Simpson wrote: If you just want this for your running program's internals this may not matter, but if you're recording the result somewhere then abspath might get you a more "stable" path in the above scenario. If a path has ".." compo

Re: Obtain the file's path.

2019-09-18 Thread Pankaj Jangid
Cameron Simpson writes: > On 17Sep2019 15:09, Hongyi Zhao wrote: >>See the following two methods for obtaining the file's path: >> >>os.path.realpath(file) >>or >>os.path.abspath(os.path.expanduser(file)) >> >>Which is more robust? > > My inclination is often to use abspath, because it may bette

Re: Obtain the file's path.

2019-09-18 Thread Eryk Sun
On 9/17/19, Cameron Simpson wrote: > > If you just want this for your running program's internals this may not > matter, but if you're recording the result somewhere then abspath might > get you a more "stable" path in the above scenario. If a path has ".." components, the abspath() result may be

Re: Obtain the file's path.

2019-09-17 Thread Cameron Simpson
On 17Sep2019 15:09, Hongyi Zhao wrote: See the following two methods for obtaining the file's path: os.path.realpath(file) or os.path.abspath(os.path.expanduser(file)) Which is more robust? They're probably equally robust (BTW, you need the expanduser in the realpath call as well, if your f