Skip to content

Make "<Binary: 2427344 bytes>" easier to read #1712

@simonw

Description

@simonw

Binary: 2,427,344 bytes would be nicer - even better, include a tooltip showing that size translated using this function:

def format_bytes(bytes):
current = float(bytes)
for unit in ("bytes", "KB", "MB", "GB", "TB"):
if current < 1024:
break
current = current / 1024
if unit == "bytes":
return f"{int(current)} {unit}"
else:
return f"{current:.1f} {unit}"

CleanShot 2022-04-12 at 11 15 04@2x

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions