Re: How to port bytes formatting to Python 3.x ?
Baptiste Lepilleur, 01.01.2011 12:53:
> 2011/1/1 Stefan Behnel
>> Baptiste Lepilleur, 01.01.2011 10:01:
>>> 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:
>> 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.
> Is there a robust implementation of the format operator % for bytes that can
> substitute %s?
Concatenation is portable and seems to suite your examples (which you
stripped above). For more involved cases (as are also likely to occur in
network protocol code), have a look at the struct module.
|All times are GMT. The time now is 01:42 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.