Python 3 __bytes__ method

E

Ethan Furman

Python 3 has a new method, __bytes__. The docs say: Called by bytes() to compute a byte-string representation of an
object. This should return a bytes object.

I must admit I'm not entirely clear how this should be used. Is anyone using this now? If so, how?
 
T

Thomas Rachel

Am 12.01.2014 01:24 schrieb Ethan Furman:
I must admit I'm not entirely clear how this should be used. Is anyone
using this now? If so, how?

I am not, as I currently am using Py2, but if I would, I would do it e.
g. for serialization of objects in order to send them over the line or
to save them into a file. IOW, the same purpose as we havd on __str__ in
Py2.


Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top