class bz2.BZ2File(filename, mode='r', buffering=None, compresslevel=9) 
Open a bzip2-compressed file in binary mode.
If filename is a str or bytes object, open the named file directly. Otherwise, filename should be a file object, which will be used to read or write the compressed data.
The mode argument can be either 'r' for reading (default), 'w' for overwriting, 'x' for exclusive creation, or 'a' for appending. These can equivalently be given as 'rb', 'wb', 'xb' and 'ab' respectively.
If fi