In [1]:
f = open('myfile.txt', 'w')

In [3]:
print dir(f)


['__class__', '__delattr__', '__doc__', '__enter__', '__exit__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'close', 'closed', 'encoding', 'errors', 'fileno', 'flush', 'isatty', 'mode', 'name', 'newlines', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'softspace', 'tell', 'truncate', 'write', 'writelines', 'xreadlines']

In [4]:
f.write("this is python classs\n")
f.write("this class staRTS at 08:45 AM")

In [5]:
f.close()

In [6]:
f = open('myfile.txt', 'w')
f.write("this is python classs\n")
f.close()

In [7]:
f = open('myfile.txt', 'a')
f.write("this is python classs\n")
f.close()

In [8]:
f = open('myfile.txt', 'w')
f.write("this is python classs\n")

In [9]:
f.flush()

In [10]:
f.closed


Out[10]:
False

In [11]:
f.close()

In [12]:
f = open('myfile.txt', 'w')
f.write("this is python classs\n")

In [14]:
f.tell()


Out[14]:
23L

In [15]:
len("this is python classs\n")


Out[15]:
22

In [16]:
f.seek.__doc__


Out[16]:
'seek(offset[, whence]) -> None.  Move to new file position.\n\nArgument offset is a byte count.  Optional argument whence defaults to\n0 (offset from start of file, offset should be >= 0); other values are 1\n(move relative to current position, positive or negative), and 2 (move\nrelative to end of file, usually negative, although many platforms allow\nseeking beyond the end of a file).  If the file is opened in text mode,\nonly offsets returned by tell() are legal.  Use of other offsets causes\nundefined behavior.\nNote that not all file objects are seekable.'

In [17]:
f.seek(0)

In [18]:
f.tell()


Out[18]:
0L

In [19]:
f.write("this class staRTS at 08:45 AM")

In [20]:
f.close()

In [21]:
f = open('myfile.txt', 'a')
f.write("this is python classs\n")
f.close()

In [22]:
f = open('myfile.txt', 'r')

In [23]:
f.read()


Out[23]:
'this class staRTS at 08:45 AMthis is python classs\n'

In [24]:
f.close()

In [25]:
f = open('myfile.txt', 'r')
f.tell()


Out[25]:
0L

In [26]:
f.seek(20)

In [27]:
f.tell()


Out[27]:
20L

In [28]:
f.read()


Out[28]:
' 08:45 AMthis is python classs\n'

In [29]:
f.close()

In [ ]: