Trinary operator?
Jeff Shannon
jeff at ccvcorp.com
Thu Apr 25 13:59:59 EDT 2002
In article <sepu0okxo8.fsf at pc970145.GermanLloyd.de>,
hoel at germanlloyd.org says...
> Jeff Shannon <jeff at ccvcorp.com> writes:
>
> > ...The only effective difference between 1 and True,=20
> > and 0 and False, is how it's written, but they add, subtract,=20
> > multiply, and hash the same.
>
> But there is a difference:
>
> >python
> Python 2.2.1 (#1, Apr 10 2002, 17:11:02)=20
> [GCC 3.0.4] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
> >>> a =3D 1
> >>> b =3D 1
> >>> a is b
> 1
> >>> a =3D True
> >>> a is b
> 0
> >>>=20
Yes, True and False are singleton objects that have a different
identity than 1 and 0. The 'is' operator tests object identity.
>>> a = []
>>> b = []
>>> a is b
0
>>>
This doesn't change the fact that a and b are equivalent, and I
would still say that there is no effective difference between a
and b, here. Just different object IDs.
--
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list