absolute path to a file

Chris Angelico rosuav at gmail.com
Fri Aug 16 12:37:14 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|
>
>
> Notes:
> Chris, I only mention the extra leading slash on my Mac in case anyone
> wonders why it is there. Python puts it there to escape the following slash.

I still don't understand what you mean by that, because there's no
concept of "escaping" with these slashes. It looks like you're
actually working with absolute paths (starting with the leading slash)
when you want to work with relative paths (NOT starting with a leading
slash). The double slash isn't "escaping" anything, to my knowledge,
and Python would not add it.

>From the look of things, you really are getting a valid absolute path
- "/image01.tif" is already absolute. It just isn't the path you want.

ChrisA



More information about the Python-list mailing list