W
Wesley Brooks
Dear Users,
I'm in the process of adding assert statements to a large piece of
code to aid with bug hunting and came across the following issue;
Using python in a terminal window you can do the following:
I would like to check that an object is a class, here's an example:
.........self.c = 1
.....def d(self):
.........print self.c
But the following fails:
File "<stdin>", line 1, in ?
NameError: name 'classobj' is not defined
For the time being I'll use b.__name__ == b to ensure I'm getting the
right class. Is there a reason why the other types such as bool are
defined but classobj isn't?
I'm running the following version of python:
Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Cheers,
Wesley Brooks
I'm in the process of adding assert statements to a large piece of
code to aid with bug hunting and came across the following issue;
Using python in a terminal window you can do the following:
Truetype(False) == bool
I would like to check that an object is a class, here's an example:
.....def __init__(self):class b:
.........self.c = 1
.....def d(self):
.........print self.c
<type 'classobj'>type(b)
But the following fails:
Traceback (most recent call last):type(b) == classobj
File "<stdin>", line 1, in ?
NameError: name 'classobj' is not defined
For the time being I'll use b.__name__ == b to ensure I'm getting the
right class. Is there a reason why the other types such as bool are
defined but classobj isn't?
I'm running the following version of python:
Python 2.4.3 (#1, Jun 13 2006, 11:46:08)
[GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2
Cheers,
Wesley Brooks