Do all file objects in the Python standard library have a `name` attribute?

Basic file objects have the name

ie attribute

>>> open("/dev/null").name
'/dev/null'

      

Do all other file types (like GzipFile) in the standard library have this attribute?

+3


source to share


1 answer


No, for example StringIO is a file-like object with no attribute name

. Most of the objects associated with the actual file have it, but this is not guaranteed.



+4


source







All Articles