Skip to main content

Make repr of bytes better in ipython

Project description

mimebytes

  • Make repr of bytes better in ipython
  • Rich outputs in Jupyter using _repr_png_ and _repr_jpeg_
In [1]: from mimebytes import ImageBytes

In [2]: with open('image.png', 'rb') as f:
   ...:     content = f.read()

In [3]: ImageBytes(content, 'image/png')
Out[3]: ImageBytes<376151> (image/png)

preview

Why?

Have you ever tried to output a bytes object in ipython and seen a garbled mess like the following? If so, then this is for you.

In [1]: with open('image.png', 'rb') as f:
   ...:     content = f.read()
   ...:

In [2]: content
Out[2]: b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x02\x00\x00\x00\x01\xd1\x08\x06\x00\x00\x00\x1c\xf2\x01\xed\x00\x00 \x00IDATx\x9c\xec\xbdy\x9cfWU\xef\xfd\xddk\xefs\x9e\xb1\xc6\xee\xeaNO\xe9$\x9d9\x84$\x1d\x08\x19\x84@\x80\x10@\x01\x15d\x14D\x05\x15\x05\x05\xe1\xe2\xf0^\xbdr\xf5\xeau\x06\x04E#*<... continues on forever>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mimebytes-0.1.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

mimebytes-0.1.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file mimebytes-0.1.1.tar.gz.

File metadata

  • Download URL: mimebytes-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mimebytes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8ea0145d41e3f7c7c53afb34b85e6bff87ad8b9c201aba1c9b25661a0539d15e
MD5 9dd361addefc71c46890e069d3f9ee06
BLAKE2b-256 28ccdcd90873abb247867fee6a369470c1fd5b3b27468bb485ae0509c016d339

See more details on using hashes here.

File details

Details for the file mimebytes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mimebytes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for mimebytes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 668eaaaac09516ab81a1d8e8f297a2587d4d46b529559ec57132cc671b29cbd9
MD5 a221a9133ab0e3072897f83622c549ab
BLAKE2b-256 80f298b1dcfdc998a2d9b6b4f321a74b09db254003a01eb1d003babc368f0bfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page