Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>> .encode('base64') -> import base64; base64.b64encode()

Just a nitpick on this. This is actually a Python "gotcha". You'll notice that the .encode('base64') method actually is a base-64 Content-Transfer-Encoding[1] which enforces a limit on the length of the line to 76 characters. Here's an example demonstrating the difference:

    import base64
    eighty_chars = ("X" * 80)
    assert '\n' in eighty_chars.encode('base64').strip()
    assert '\n' not in base64.b64encode(eighty_chars)
[1] http://tools.ietf.org/html/rfc3548#2.1


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: