YouTip LogoYouTip

Os Pathconf

# Python2.x Python os.pathconf() Method [![Image 3: Python File Methods](#) Python OS File/Directory Methods](#) * * * ### Overview The os.pathconf() method is used to return system configuration information for an open file. Available on Unix platforms. ### Syntax The syntax for the **fpathconf()** method is as follows: os.fpathconf(fd, name) ### Parameters * **fd** -- File descriptor * **name** -- The system configuration value to retrieve. It may be a string defining a system value, specified in many standards (POSIX.1, Unix 95, Unix 98, and others). Some platforms also define additional names. These names are in the `pathconf_names` dictionary on the main operating system. For configuration variables not in `pathconf_names`, it is also acceptable to pass a number as the name. ### Return Value Returns the system information of the file. ### Example The following example demonstrates the use of the fpathconf() method: #!/usr/bin/python# -*- coding: UTF-8 -*-import os, sys # Open file fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )print "%s" % os.pathconf_names # Get maximum number of links to the file no = os.fpathconf(fd, 'PC_LINK_MAX')print "Maximum number of links to the file. :%d" % no# Get maximum length of a filename no = os.fpathconf(fd, 'PC_NAME_MAX')print "Maximum length of a filename :%d" % no# Close file os.close( fd)print "File closed successfully!!" Executing the above program outputs the following result: File closed successfully!! [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Python Tk FrameLinux Comm Poweroff β†’