Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to check if object is of file type in python3

# In python3, file objects are part of the io module.
>>> from io import IOBase
>>> f = open(<filePath>, 'w')
>>> isinstance(f, IOBase)
True
>>> isinstance(object(), IOBase)
False
 
PREVIOUS NEXT
Tagged: #check #object #file #type
ADD COMMENT
Topic
Name
4+6 =