This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: tempfile files not types.FileType
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: rhettinger, vannieuwenhoven
Priority: normal Keywords:

Created on 2005-01-10 15:29 by vannieuwenhoven, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg23920 - (view) Author: Frans van Nieuwenhoven (vannieuwenhoven) Date: 2005-01-10 15:29
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)
msg23921 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-01-11 15:36
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.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41419
2005-01-10 15:29:58vannieuwenhovencreate