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


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


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.



All Articles