Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 os.pathconf() Method

Python3 os.pathconf() Method

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


Overview

The os.pathconf() method returns system configuration information for an open file.

Available on Unix platforms.

Syntax

The **fpathconf()** method syntax is as follows:


os.fpathconf(fd, name)

Parameters

Return Value

Returns the system information of the file.

Example

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


#!/usr/bin/python3

import os, sys

# Open file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

print ("%s" % os.pathconf_names)

# Get maximum file connections
no = os.fpathconf(fd, 'PC_LINK_MAX')
print ("Maximum number of links to the file. :%d" % no)

# Get maximum filename length
no = os.fpathconf(fd, 'PC_NAME_MAX')
print ("Maximum length of a filename :%d" % no)

# Close file
os.close( fd)

print ("关闭文件成功!!")

The output of the above program is:


关闭文件成功!!

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