absolute path to a file

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Aug 16 19:07:56 EDT 2019


> On Sat, Aug 17, 2019 at 2:27 AM Paul St George <email at paulstgeorge.com> wrote:
> 
>>BUT does not work with
>>| print('test2:',os.path.realpath(n.image.filepath))|
>>
>>This returns only
>>|/image01.tif|

What does n.image.filepath look like on its own? If it starts
with a leading slash, then os.path.realpath will think it's
already an absolute path and leave it alone.

The problem then is why it's getting a leading slash in the
first place. It looks like the result of something naively
trying to append a filename to an empty directory path.

-- 
Greg



More information about the Python-list mailing list