On Sat, Aug 17, 2019 at 5:28 AM Paul St George <em...@paulstgeorge.com> wrote: > > On 16/08/2019 18:37, Chris Angelico wrote: > > On Sat, Aug 17, 2019 at 2:27 AM Paul St George <em...@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 > > > > Yes, perhaps I am using the wrong terms. I want to find the path that > looks like this: > /Users/Lion/Desktop/test8/image01.tif > > With such a path, I can find the image file. I cannot find the file with > only /image01.tif > > It is safe to ignore what I said about the double forward slashes. I am > not using these. I only observed their presence and made a guess at > their meaning. >
When your path starts with "/Users", that means the Users directory which is found in the root directory of your hard drive. When your path starts with "/image01.tif", that means that image01.tif needs to be in the root directory. If that's not the case (which I highly suspect), then you do NOT want a leading slash - just use "image01.tif", which means the file should be in the *current* directory. ChrisA -- https://mail.python.org/mailman/listinfo/python-list