Python Tutorial ( PDFDrive )
• st_dev: device.• st_nlink: number of hard links.• st_uid: user id of owner.• st_gid: group id of owner.• st_size: size of file, in bytes.• st_atime: time of most recent access.• st_mtime: time of most recent content modification.• st_ctime: time of most recent metadata change.Example The following example shows the usage of stat() method.# !/usr/bin/pythonimport os, sys# showing stat information of file "a2.py"statinfo = os.stat('a2.py')print statinfoLet us compile and run the above program, this will produce the following result:posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L, st_nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=1330498089, st_ctime=1330498089)os.stat_float_times([newvalue]) Description The method stat_float_times() determines whether stat_result represents time stamps as float objects.Syntax Following is the syntax for stat_float_times() method:os.stat_float_times([newvalue])Parameters • newvalue -- If newvalue is True, future calls to stat() return floats, if it is False, future calls return ints. Ifnewvalue is not mentioned, it returns the current settings.Return Value This method returns true or false.Example The following example shows the usage of stat_float_times() method.# !/usr/bin/pythonimport os, sysTUTORIALS POINT Simply Easy Learning
# stat informationstatinfo = os.stat('a2.py')print statinfostatinfo = os.stat_float_times()print statinfoLet us compile and run the above program, this will produce the following result:posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L,st_nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=1330498089, st_ctime=1330498089)Trueos.statvfs(path) Description The method statvfs() performs a statvfs system call on the given path.Syntax Following is the syntax for statvfs() method:os.statvfs(path)Parameters • path -- This is the path whose statvfs information is required.Return Value Here is the list of members of statvfs structure:• f_bsize: preferred file system block size.• f_frsize: fundamental file system block size.• f_blocks: total number of blocks in the filesystem.• f_bfree: total number of free blocks.• f_bavail: free blocks available to non-super user.• f_files: total number of file nodes.• f_ffree: total number of free file nodes.• f_favail: free nodes available to non-super user.• f_flag: system dependent.• f_namemax: maximum file name length.Example The following example shows the usage of statvfs() method.# !/usr/bin/pythonTUTORIALS POINT Simply Easy Learning
- Page 239 and 240: Description The method writelines()
- Page 241 and 242: 14151617181920212223242526272829303
- Page 243 and 244: 53545556575859606162os.symlink(src,
- Page 245 and 246: Return Value This method does not
- Page 247 and 248: • stat.S_IRGRP: Read by group.•
- Page 249 and 250: os.chroot("/tmp/usr")print "Changed
- Page 251 and 252: Parameters • fd -- This is the or
- Page 253 and 254: import os, sys# First go to the "/v
- Page 255 and 256: Description The method fchown() cha
- Page 257 and 258: Description The method fdopen() ret
- Page 259 and 260: {'PC_MAX_INPUT': 2, 'PC_VDISABLE':
- Page 261 and 262: Example The following example shows
- Page 263 and 264: # Open a filefd = os.open( "foo.txt
- Page 265 and 266: print "Current working dir : %s" %
- Page 267 and 268: path = "/var/www/html/foo.txt"fd =
- Page 269 and 270: Example The following example shows
- Page 271 and 272: _vti_txtrobots.txtitemlistingresume
- Page 273 and 274: # Close opened fileos.close( fd )#
- Page 275 and 276: dev_num = os.makedev(major_dnum, mi
- Page 277 and 278: Return Value This method does not
- Page 279 and 280: -rw-------. 1 root root 0 Apr 30 02
- Page 281 and 282: os.pathconf(path, name) Descriptio
- Page 283 and 284: Description The method popen() open
- Page 285 and 286: # !/usr/bin/pythonimport ossrc = '/
- Page 287 and 288: Syntax Following is the syntax for
- Page 289: Return Value This method does not
- Page 293 and 294: Description The method tcgetpgrp()
- Page 295 and 296: os.tempnam(dir, prefix)Parameters
- Page 297 and 298: Description The method ttyname() re
- Page 299 and 300: Return Value This method does not
- Page 301 and 302: Return Value This method returns t
- Page 303 and 304: KeyErrorNameErrorUnboundLocalErrorE
- Page 305 and 306: ......................else:If there
- Page 307 and 308: print "Error: can\'t find file or r
- Page 309 and 310: self.args = argSo once you defined
- Page 311 and 312: 'Optional class documentation strin
- Page 313 and 314: For the above class let's try to ac
- Page 315 and 316: print 'Calling child method'c = Chi
- Page 317 and 318: Data Hiding: An object's attribute
- Page 319 and 320: groups()This method returns all mat
- Page 321 and 322: SYNTAX: re.sub(pattern, repl, strin
- Page 323 and 324: \s Matches whitespace. Equivalent t
- Page 325 and 326: Backreferences: This matches a prev
- Page 327 and 328: CHAPTER20Python CGI ProgrammingWhat
- Page 329 and 330: If you click hello.py, then this pr
- Page 331 and 332: Simple URL Example : Get Metho
- Page 333 and 334: </form>The result of this code is t
- Page 335 and 336: text_content = form.getvalue('textc
- Page 337 and 338: Here is an example of how to retrie
- Page 339 and 340: CHAPTER21Python Database AccessThe
# stat information
statinfo = os.stat('a2.py')
print statinfo
statinfo = os.stat_float_times()
print statinfo
Let us compile and run the above program, this will produce the following result:
posix.stat_result(st_mode=33188, st_ino=3940649674337682L, st_dev=277923425L,
st_nlink=1, st_uid=400, st_gid=401, st_size=335L, st_atime=1330498089, st_mtime=13
30498089, st_ctime=1330498089)
True
os.statvfs(path)
Description
The method statvfs() performs a statvfs system call on the given path.
Syntax
Following is the syntax for statvfs() method:
os.statvfs(path)
Parameters
• path -- This is the path whose statvfs information is required.
Return Value
Here is the list of members of statvfs structure:
• f_bsize: preferred file system block size.
• f_frsize: fundamental file system block size.
• f_blocks: total number of blocks in the filesystem.
• f_bfree: total number of free blocks.
• f_bavail: free blocks available to non-super user.
• f_files: total number of file nodes.
• f_ffree: total number of free file nodes.
• f_favail: free nodes available to non-super user.
• f_flag: system dependent.
• f_namemax: maximum file name length.
Example
The following example shows the usage of statvfs() method.
# !/usr/bin/python
TUTORIALS POINT
Simply Easy Learning