Python3 Os Lstat
# Python3.x Python3 os.lstat() Method
[ Python3 OS File/Directory Methods](#)
* * *
### Overview
The os.lstat() method is used to return file information similar to stat(), but does not follow symbolic links. On some platforms, this is an alias for fstat, for example on Windows.
### Syntax
The syntax for the **lstat()** method is as follows:
os.lstat(path)
### Parameters
* **path** -- The file for which to return information.
### Return Value
Returns file information.
### Example
The following example demonstrates the use of the lstat() method:
#!/usr/bin/python3import os, sys # Open a file path = "/var/www/html/foo.txt" fd = os.open( path, os.O_RDWR|os.O_CREAT )# Close opened file os.close( fd )# Get tuple info = os.lstat(path)print ("File Info :", info)# Get file uidprint ("File UID :%d" % info.st_uid)# Get file gidprint ("File GID :%d" % info.st_gid)
The output of executing the above program is:
File Info : (33261, 3450178L, 103L, 1, 500, 500, 0L, 1238866944, 1238866944, 1238948312)File UID :500File GID :500
[ Python3 OS File/Directory Methods](#)
YouTip