Hello dear readers! Welcome back to another section of our tutorial on Python. In this tutorial guide, we are going to be studying about the Os chflags() method.
Python os chflags() method sets the flags of path to the numeric flags. The flags may take a mixture of various values described below.
Note - This method is available in Python version 2.6 onwards. Most of the flags can only be changed by super user only.
Python os chflags() method sets the flags of path to the numeric flags. The flags may take a mixture of various values described below.
Note - This method is available in Python version 2.6 onwards. Most of the flags can only be changed by super user only.
Syntax
The following below is the syntax for Python Os chflags() method -
os.chflags(path, flags)
RECOMMENDED POST: Python os.chdir() Method with example
Parameter Details
- path - This is the complete path of the directory to be changed to a new location.
- flags - The flag specified are formed by OR'ing the below values -
- os.UF_NODUMP - Do not dump the file.
- os.UF_IMMUTABLE - The file may be static and not changed.
- os.UF_APPEND - The file may be appended to.
- os.UF_NOUNLINK - The file may not be renamed or deleted.
- os.UF_OPAQUE - The file directory is opaque when viewed through a union stack.
- os.SF_ARCHIVED - The file may be archived.
- os.SF_IMMUTABLE - The file may not be changed.
- os.SF_APPEND - The file may be appended to.
- os.SF_NOUNLINK - The file may not be deleted or renamed.
- os.SF_SNAPSHOT - It is a snapshot file.
Return Value
It does not return any value.
Example
The following below is a simple example -
#!/usr/bin/python import os import stat path = "/tmp/foo.txt" # Set a flag so that file may not be renamed or deleted. flags = os.SF_NOUNLINK retval = os.chflags( path, flags) print "Return Value: %s" % retval
Output
When the above code is executed, it will produce the following result -
Return Value : None
RECOMMENDED POST: Python File truncate() Method with example
Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we are going to be studying about the Python OS chmod() Method.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.