isinstance( True, int ) returns True
However, the code
def foo( arg ):
if isinstance( arg, bool ):
_foo_bool( arg )
else:
_foo_other( arg )
Would work in theory.
I could do this. I'm just annoyed that BP is not doing it for me.
-----Original Message-----
From:
cplusplus-sig-bounces+matthew.scouten=tradingtechnologies....@python.org
[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies....@py
thon.org] On Behalf Of Hans Meine
Sent: Tuesday, March 17, 2009 5:03 AM
To: Development of Python/C++ integration
Subject: Re: [C++-sig] strange behavior with respect to numeric and
Booleanoverloads
On Monday 16 March 2009 22:52:16 Ralf W. Grosse-Kunstleve wrote:
> [...] Boost.Python 2 was written when the Python bool type still
really
> was an int (Python 2.2). [...]
On Tuesday 17 March 2009 06:40:14 Roman Yakovenko wrote:
> Python code:
>
> def foo( arg ):
> if isinstance( arg, int ):
> _foo_int( arg )
> else:
> _foo_bool( arg )
Now I am confused. Both of the above read as if a boolean was no longer
an
int, but I interpret "is a" and "isinstance" as checking for types
inherited
from, too?! While Ralf could have meant (True is 1) with his "really",
the
above code should first test whether isinstance( arg, bool ), no?
Or did this change with 2.6/3?
Greetings,
Hans
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig