
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get File's Permission Mask Using Python
To get stat of a file, method stat() from the os module can be used. It performs a stat system call on the given path. For example,
import os st = os.stat("file.dat")
This function takes the name of a file, and returns a 10-member tuple with the following contents:
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime)
The mode variable gives you the information about file permissions. You can get it by st[0]. You can read more about interpreting the tuple here: http://effbot.org/zone/python-fileinfo.htm
Advertisements