How to port bytes formatting to Python 3.x ?
Stefan Behnel
stefan_ml at behnel.de
Sat Jan 1 05:58:48 EST 2011
More information about the Python-list mailing list
Sat Jan 1 05:58:48 EST 2011
- Previous message (by thread): How to port bytes formatting to Python 3.x ?
- Next message (by thread): How to port bytes formatting to Python 3.x ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Baptiste Lepilleur, 01.01.2011 10:01:
> Hi,
> I'm trying to port a small library to Python 3.x, and I'm wondering what is
> the best way to port statements such as the one belows that are frequently
> found in network protocol implementation:
>
> headerparts = ("%s:%s\n" % (key, value) for key, value in
> headers.iteritems())
> framebytes = "%s\n%s\n%s\x00" % (command, "".join(headerparts),
> body)
>
> Where all manipulated string are actually bytes, though value in headers
> dict may be any objects.
See my answer in the other thread you started on this topic. You need to
wrap the literal in a function call that converts it to a bytes literal
when running in Python 3.
Stefan
- Previous message (by thread): How to port bytes formatting to Python 3.x ?
- Next message (by thread): How to port bytes formatting to Python 3.x ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list