[Python-ideas] Fwd: Python Convert

Chris Angelico rosuav at gmail.com
Fri Jul 12 06:30:08 CEST 2013


On Fri, Jul 12, 2013 at 2:10 PM, Daniel Rode <dth4h95 at gmail.com> wrote:
> It could be used to convert a string to an integer (if applicable).

How do you convert the string "1234" to integer? Is it:

* 1234 (decimal digits)?
* 825373492 (big-endian 32-bit, treating the characters as ASCII)?
* 875770417 (little-endian, ditto)?
* Something else?

The first one is spelled int(s), the second and third can probably
best be done with ctypes or struct, but there's certainly no single
obvious way to "encode" one as the other.

ChrisA


More information about the Python-ideas mailing list