When is an int not an int? Who can explain this?
Charles T. Smith
cts.private.yahoo at gmail.com
Mon Jan 18 11:28:49 EST 2016
On Tue, 19 Jan 2016 03:19:59 +1100, Chris Angelico wrote:
> On Tue, Jan 19, 2016 at 3:11 AM, Charles T. Smith
> <cts.private.yahoo at gmail.com> wrote:
>> $ python
>> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> type(0) is int
>> True
>> ...
>> (PDB)type(0) is int
>> False
>> (PDB)type(1) is int
>> False
>
> Possibility #1: 'int' has been rebound.
>
> Possibility #2: 'type' has been rebound.
>
> I'd check them in that order.
>
> ChrisA
But:
(PDB)p 5 + 0
5
(PDB)class c (object): pass
(PDB)type (c()) is c
True
Okay, I think I understand it now:
(PDB)type (int)
<type 'module'>
(PDB)type (float)
<type 'type'>
More information about the Python-list
mailing list