Python Forum
to follow or not to follow a symlink in os.utime() os POSIX
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
to follow or not to follow a symlink in os.utime() os POSIX
#1
in "16.1. os — Miscellaneous operating system interfaces" there is this text (in my PDF copy of "The Python Library Reference"):
Output:
You can check whether or not follow_symlinks is supported on your platform using os.supports_follow_symlinks. If it is unavailable, using it will raise a NotImplementedError
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).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
(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
True
It 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.
Reply
#3
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?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
(Sep-03-2023, 06:28 PM)Gribouillis Wrote: os.stat in os.supports_follow_symlinks
and it gives a set of functions that the support applies to (as opposed to all functions documented with that argument)?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
(Sep-04-2023, 01:31 AM)Skaperen Wrote: and it gives a set of functions that the support applies to
Exactly
>>> 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>}
>>> 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  bluestacks instagram follow bot countingclub 2 2,479 May-03-2021, 05:03 AM
Last Post: countingclub

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020