Issue 1099516: tempfile files not types.FileType (original) (raw)

Issue1099516

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:09 admin set github: 41419
2005-01-10 15:29:58 vannieuwenhoven create