How to check that a path has a sticky bit in python?

How to check with python if a path has the sticky bit set?


Asked by: Max288 | Posted: 24-09-2021






Answer 1

import os
def is_sticky(path):
    return os.stat(path).st_mode & 01000 == 01000

Answered by: Carina412 | Posted: 25-10-2021



Answer 2

os.stat() will return a tupple of information about the file. The first item will be the mode. You would then be able to use some bit arithmetic to get for the sticky bit. The sticky bit has an octal value of 1000.

Answered by: Ryan400 | Posted: 25-10-2021



Similar questions





Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top