to follow or not to follow a symlink in os.utime() os POSIX - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: to follow or not to follow a symlink in os.utime() os POSIX (/thread-40662.html) |
to follow or not to follow a symlink in os.utime() os POSIX - Skaperen - Sep-03-2023 in "16.1. os — Miscellaneous operating system interfaces" there is this text (in my PDF copy of "The Python Library Reference"): what is meant by "using"? trying to access it as an attribute? checking if the attribute exists? what is the appropriate way to test if the platform a script is running on supports this?my experience from my days of coding most everything in C told me that every platform supported following a symlink and some did NOT support NOT following a symlink. so, it seems this test should be the other way around. there should be os.supports_nofollow_symlinks which would be like AT_SYMLINK_NOFOLLOW in C (defined in fcntl.h so utimnsat(2) can use it). RE: to follow or not to follow a symlink in os.utime() os POSIX - Gribouillis - Sep-03-2023 (Sep-03-2023, 05:34 PM)Skaperen Wrote: what is meant by "using"? trying to access it as an attribute?They mean that some functions in the os module have a follow_symlinks= keyword argument in their parameter list, for example the os.stat()function has such a parameter. On my system, I have >>> import os >>> os.stat in os.supports_follow_symlinks TrueIt means that I can use the follow_symlinks argument and call e.g. os.stat(..., follow_symlinks=False)On other systems, one cannot set this argument to False. RE: to follow or not to follow a symlink in os.utime() os POSIX - Skaperen - Sep-04-2023 so, you are saying "You can check whether or not follow_symlinks is supported on your platform" refers to support of the keyword argument by the Python implementation/configuration on your platform/host, not support of that being doable by the platform? RE: to follow or not to follow a symlink in os.utime() os POSIX - Skaperen - Sep-04-2023 (Sep-03-2023, 06:28 PM)Gribouillis Wrote: os.stat in os.supports_follow_symlinksand it gives a set of functions that the support applies to (as opposed to all functions documented with that argument)? RE: to follow or not to follow a symlink in os.utime() os POSIX - Gribouillis - Sep-04-2023 (Sep-04-2023, 01:31 AM)Skaperen Wrote: and it gives a set of functions that the support applies toExactly >>> import os >>> os.supports_follow_symlinks {<built-in function link>, <built-in function chown>, <built-in function utime>, <built-in function stat>, <built-in function access>} >>> |