Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python File flush() Method


previous next AddThis Social Bookmark Button


Description:

This method flushes the internal buffer, like stdio's fflush. This may be a no-op on some file-like objects.

Python automatically flushes the files when closing them. But you may want to flush the data before closing any file.

Syntax:

fileObject.flush(); 

Parameters:

Here is the detail of parameters:

  • NA

Example:

#!/usr/bin/python

# Open a file
fo = open("foo.txt", "wb")
print "Name of the file: ", fo.name

# Here it does nothing, but you can call it with read operation.
fo.flush()

# Close opend file
fo.close()

This produces following result:

Name of the file:  foo.txt


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names