Hi, I found a problem which can be a bug and want to inform you. it seems os.islink() and PATH(mypath).is_symlink() functions doen't work correct when there is linked folder inside the path: For example I have the following path: a/b/c/test.txt if my c folder is link these 2 functions will not show that this path is link Only if i remove test.txt and use a/b/c path is shows that path is link. Seems these functions checks only last part of given path not full path and doesn't find if there is link in somewere inside path and shows not correct result. Interesting to know your opinion regarding it.
The docs say, eg: "Return True if the path points to a symbolic link". The path points to a file system object, and it is the object that is being checked, not each component of the path used to get to that object.
Hi David Thanks for support. one question. I couldn't find a function which will check full path is link or not. Is there any known function> >Четверг, 24 августа 2017, 17:38 +04:00 от "R. David Murray" <report@bugs.python.org>: > > >R. David Murray added the comment: > >The docs say, eg: "Return True if the path points to a symbolic link". The path points to a file system object, and it is the object that is being checked, not each component of the path used to get to that object. > >---------- >nosy: +r.david.murray >resolution: -> not a bug >stage: -> resolved >status: open -> closed > >_______________________________________ >Python tracker < report@bugs.python.org > >< http://bugs.python.org/issue31269 > >_______________________________________
I would phrase that as "check if any of the components of the path are links", at which point one "obvious"[*] answer is "any(x.is_symlink() for x in [*mypath.parents, mypath])". If the path is absolute, you could use "not (mypath.resolve() == mypath)". [*] I put that in quotes because it is only obvious once you have a non-trivial amount of experience with programming in Python.
Thanks a lot David >Четверг, 24 августа 2017, 18:42 +04:00 от "R. David Murray" <report@bugs.python.org>: > > >R. David Murray added the comment: > >I would phrase that as "check if any of the components of the path are links", at which point one "obvious"[*] answer is "any(x.is_symlink() for x in [*mypath.parents, mypath])". If the path is absolute, you could use "not (mypath.resolve() == mypath)". > >[*] I put that in quotes because it is only obvious once you have a non-trivial amount of experience with programming in Python. > >---------- > >_______________________________________ >Python tracker < report@bugs.python.org > >< http://bugs.python.org/issue31269 > >_______________________________________
History
Date
User
Action
Args
2022-04-11 14:58:51
admin
set
github: 75452
2017-08-25 06:39:09
karaV
set
messages: +
2017-08-24 14:42:23
r.david.murray
set
messages: +
2017-08-24 14:08:53
karaV
set
messages: +
2017-08-24 13:37:57
r.david.murray
set
status: open -> closednosy: + r.david.murraymessages: + resolution: not a bugstage: resolved
2017-08-24 13:27:58
karaV
set
title: bug in islink() and is_simlink() -> bug in islink() and is_symlink()