Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to port bytes formatting to Python 3.x ?

Reply
Thread Tools

Re: How to port bytes formatting to Python 3.x ?

 
 
Stefan Behnel
Guest
Posts: n/a
 
      01-01-2011
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.

http://docs.python.org/py3k/library/struct.html

Stefan

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Ratio of Bytes Delayed to Bytes Sent netproj Cisco 0 12-21-2005 08:08 PM
Private Bytes vs. # Bytes in all Heaps in Perfmon Jason Collins ASP .Net 3 02-18-2004 03:59 PM
Re: receiving Bytes and sending Bytes Ieuan Adams Computer Support 0 07-24-2003 07:46 PM
Re: receiving Bytes and sending Bytes The Old Sourdough Computer Support 0 07-23-2003 01:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57