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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With