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: Daniel837 | Posted: 28-01-2022

Answer 1

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

Answered by: Luke824 | Posted: 01-03-2022

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: John823 | Posted: 01-03-2022

Similar questions

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

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