Reputation: 1177
Basic file objects have a name
attribute i.e.
>>> open("/dev/null").name
'/dev/null'
Do all other file-like types (e.g. GzipFile) in the standard library have this attribute?
Upvotes: 3
Views: 104
Reputation: 14369
No, for example a StringIO is a file-like object without name
attribute. Most objects that are associated to an actual file have it, but it is not guaranteed.
Upvotes: 4