From db2900b857e71e6700b6b959be44baddb64ac850 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Thu, 16 Jul 2009 18:14:03 -0400 Subject: [PATCH] beginning #file-objects --- files.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/files.html b/files.html index 79da47c..6419963 100644 --- a/files.html +++ b/files.html @@ -67,18 +67,21 @@ UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 28: chara

File Objects

-

FIXME - -

Python has a built-in function, open(), for opening a file on disk. The open() function returns a file object, which has methods and attributes for getting information about and manipulating the file. +

So far, all we know is that Python has a built-in function called open(). The open() function returns a file object, which has methods and attributes for getting information about and manipulating the file.

 >>> a_file = open('examples/chinese.txt', encoding='utf-8')
->>> a_file.name
+>>> a_file.name                                              
 'examples/chinese.txt'
->>> a_file.mode
+>>> a_file.mode                                              
 'r'
->>> a_file.encoding
+>>> a_file.encoding                                         
 'utf-8'
+
    +
  1. FIXME +
  2. +
  3. +