[docs] possible error on http://docs.python.org/library/struct.html
Georg Brandl
georg at python.org
Sat Sep 25 15:33:34 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 23.09.2010 03:22, schrieb Michael Shannon:
> I was trying the example 7.3.2.3 - and when I tried:
>>>> unpack( 'hhl', '\x00\x01\x00\x02\x00\x00\x00\x03')
>
> I got the following error:
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: 'str' does not support the buffer interface
>
> However, if I declared the second string to be a byte array:
>>>> unpack( 'hhl', b'\x00\x01\x00\x02\x00\x00\x00\x03')
> (256, 512, 50331648)
> ... it works :-)
>
>
> I'm running:
> aMac:~ mike$ python3 -V
> Python 3.1.2
> aMac:~ mike$ uname -a
> Darwin dd-wrt.local 10.4.0 Darwin Kernel Version 10.4.0: Fri Apr 23 18:27:12 PDT
> 2010; root:xnu-1504.7.4~1/RELEASE_X86_64 x86_64
Hey Mike,
you're looking at the 2.7 docs, which necessarily has examples that don't
work on Python 3. Please refer to http://docs.python.org/py3k/ for the
current Python 3 docs.
cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
iEYEARECAAYFAkyd+i4ACgkQN9GcIYhpnLCLGACgjnMTx+cNSb88o9SAbiFTKfDG
3k4AoKpCfpJdK5wsHf2DEYDDt9rhAs2k
=LHOt
-----END PGP SIGNATURE-----
More information about the docs
mailing list