Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created January 23, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/a76b97a4ee462bf47f6a4350333c7cb9 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/a76b97a4ee462bf47f6a4350333c7cb9 to your computer and use it in GitHub Desktop.
header_utils.py
LENGTH_HEADER_SIZE = 8
USER_HEADER_SIZE = 16
def format_message(username, message):
if not message:
return None
length_header = f'{len(message):<{LENGTH_HEADER_SIZE}}'
user_header = f'{username:<{USER_HEADER_SIZE}}'
return f'{length_header}{user_header}{message}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment