YouTip LogoYouTip

Python3 Os Chflags

Python3 os.chflags() Method

Python3 os.chflags() Method

-- Learning More Than Just Technology, But Also Dreams!

Python 3 Tutorial

Python3 Tutorial Python3 Introduction Python3 Environment Setup Python3 VScode Python3 Basic Syntax Python3 Basic Data Types Python3 Data Type Conversion Python3 Interpreter Python3 Comments Python3 Operators Python3 Numbers Python3 Strings Python3 Lists Python3 Tuples Python3 Dictionaries Python3 Sets Python3 Conditional Statements Python3 Loop Statements Python3 First Programming Step Python3 Comprehensions Python3 Iterators and Generators Python3 with Python3 Functions Python3 lambda (Anonymous Functions) Python Decorators Python3 Data Structures Python3 Modules Python __name__ Python3 Input and Output Python3 File Python3 OS Python3 Errors and Exceptions Python3 Object-Oriented Python3 Namespace/Scope Creating Python Virtual Environments Python Type Hints Python3 Standard Library Overview Python3 Examples Python Quiz

Python3 Advanced Tutorial

Python3 Regular Expressions Python3 CGI Programming Python MySQL - mysql-connector Driver Python3 MySQL Database Connection - PyMySQL Driver Python3 Network Programming Python3 SMTP Sending Email Python3 Multithreading Python3 XML Processing Python3 JSON Data Parsing Python3 Date and Time Python3 Built-in Functions Python MongoDB Python3 urllib Python uWSGI Installation and Configuration Python3 pip Python3 operator Module Python math Module Python requests Module Python random Module Python OpenAI Python Useful Resources Python AI Drawing Python statistics Module Python hashlib Module Python Quantitative Python pyecharts Module Python selenium Library Python Web Scraping - BeautifulSoup Python Scrapy Library Python Markdown to HTML Python sys Module Python Pickle Module Python subprocess Module Python queue Module Python StringIO Module Python logging Module Python datetime Module Python re Module Python csv Module Python threading Module Python asyncio Module Python PyQt Python for Loop Python while Loop

Python3 File Python3 Errors and Exceptions

Explore In Depth

  • Software
  • Network Services
  • Web Design & Development
  • Programming Languages
  • Programming
  • Computer Science
  • Development Tools
  • Scripting Languages
  • Scripts
  • Web Service

Python3.x Python3 os.chflags() Method

Python3 OS File/Directory Methods Python3 OS File/Directory Methods


Overview

The os.chflags() method is used to set the flags of a path to numeric flags. Multiple flags can be combined using OR.

It is only supported on Unix systems.

Syntax

The syntax for the chflags() method is as follows:

os.chflags(path, flags)

Parameters

  • path -- The file path or directory path.
  • flags -- Can be one of the following values:
    • stat.UF_NODUMP: Non-dump file
    • stat.UF_IMMUTABLE: File is read-only
    • stat.UF_APPEND: File can only be appended to
    • stat.UF_NOUNLINK: File cannot be deleted
    • stat.UF_OPAQUE: Directory is opaque, viewable through the union stack
    • stat.SF_ARCHIVED: Archived file (superuser can set)
    • stat.SF_IMMUTABLE: File is read-only (superuser can set)
    • stat.SF_APPEND: File can only be appended to (superuser can set)
    • stat.SF_NOUNLINK: File cannot be deleted (superuser can set)
    • stat.SF_SNAPSHOT: Snapshot file (superuser can set)

Return Value

This method does not return a value.

Example

The following example demonstrates the use of the chflags() method:

Example

#!/usr/bin/python3

import os, stat

path = "/tmp/foo.txt"

# Set flags for the file to make it unrenamable and undeletable
flags = stat.SF_NOUNLINK

retval = os.chflags(path, flags)

print("Return value: %s" % retval)

Executing the above program produces the following output:

Return value: None

Python3 OS File/Directory Methods Python3 OS File/Directory Methods

← Python3 Os ChownPython3 Os Chflags β†’