[Python-Dev] Fun with numbers

Barry A. Warsaw barry@zope.com
Thu, 25 Apr 2002 18:46:01 -0400


Tim, Jeremy, and I are having so much fun...
:)
-Barry

-------------------- snip snip --------------------
Python 2.3a0 (#14, Apr 23 2002, 18:26:18) 
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 3 .__class__
<type 'int'>
[9903 refs]
>>> 3 .__class__ = int
[9903 refs]
>>> 3 .__class__ = float
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __class__ assignment: 'float' object layout differs from 'int'
[9939 refs]
>>> 3 .__class__ = bool
[9939 refs]
>>> 3
True
[9939 refs]
>>> 3L .__class__ = int
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: 'long' object has only read-only attributes (assign to .__class__)
[9939 refs]
>>> 23000 .__class__ = bool
Debug memory block at address p=0x814f544:
    485823496 bytes originally requested
    the 4 pad bytes at p-4 are not all FORBIDDENBYTE (0xfb):
        at p-4: 0x7a *** OUCH
        at p-3: 0x61 *** OUCH
        at p-2: 0xc8 *** OUCH
        at p-1: 0x3c *** OUCH
    the 4 pad bytes at tail=0x250a094c are Segmentation fault