[ python-Bugs-1099516 ] tempfile files not types.FileType

SourceForge.net noreply at sourceforge.net
Tue Jan 11 16:36:10 CET 2005


Bugs item #1099516, was opened at 2005-01-10 10:29
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1099516&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Frans van Nieuwenhoven (vannieuwenhoven)
Assigned to: Nobody/Anonymous (nobody)
Summary: tempfile files not types.FileType

Initial Comment:
a temporary file created with the tempfile module is
not recognized as a types.FileType

testcase:

import types
import tempfile

# this will return False (I think it should return True)
isinstance(tempfile.TemporaryFile(), types.FileType)

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2005-01-11 10:36

Message:
Logged In: YES 
user_id=80475

Clarified the doc strings, noting that a file-like object is
returned rather than an actual file.

Instead of type checking the object, it is a better practice
to use "duck typing" where you check for required methods
(the interface) instead of an actual type or subtype.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1099516&group_id=5470


More information about the Python-bugs-list mailing list