I think one of the issues is that BZ2File accepts the filename as a
name or as a file-like object!

I don't see why it couldn't be enhanced to provide the filename though
(by pulling it from the fp). Meanwhile, the ugly way to get the
filename from a BZ2File object:

pbryan@dynamo:~$ python3
Python 3.9.3 (default, Apr  8 2021, 23:35:02) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bz2
>>> f = bz2.BZ2File("test.bz2")
>>> f._fp.name
'test.bz2'
>>> 

Paul


On Tue, 2021-04-27 at 04:04 +0000, r...@panix.com wrote:
> I was surprised recently to discover that BZ2File (at least in 3.7)
> doesn't have a name attribute.  Is there some fundamental reason name
> couldn't be supported, or is it just a bug that it wasn't
> implemented?
> _______________________________________________
> Python-Dev mailing list -- python-dev@python.org
> To unsubscribe send an email to python-dev-le...@python.org
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-dev@python.org/message/N3Q7AN5ISRGKS76GT4YSJX2SV6BNQIWM/
> Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/S4KSWVFLM5JEZCI3OFWJSEKR3JUJL6XL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to