[Python-Dev] file(fileinput.input())

Aahz aahz@pythoncraft.com
Tue, 7 May 2002 00:23:23 -0400


On Tue, May 07, 2002, John Machin wrote:
>
> Since when? Where is this documented? The following simple example concords 
> with the documentation  -- "The first two arguments are the same as for
> stdio's fopen(): filename is the file name to be opened," -- and seems to
> flatly contradict you.
> 
> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys
> >>> foo = file(sys.stdout)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: coercing to Unicode: need string or buffer, file found
> >>> bar = file(sys.stdin)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: coercing to Unicode: need string or buffer, file found

Oops.  <Aahz slinks away quietly with egg on face, swearing to test more
carefully before posting again>

"I know I tested it.  Really, I did."
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

See me at OSCON!  I'm teaching Python for [Perl] Programmers, a fast intro 
for all experienced programmers (not just Perl).  Early bird ends June 10.
http://conferences.oreillynet.com/os2002/