Message101553
I'm working on a debugger, trying to identify instances of
old-style classes in Python 2, and any class in Python 3.
The getattr formulation will work, but because I already
need to maintain an "is_v3" flag, I might as well use it
here.
As a side note, how are instances of new-style classes in
v2 categorized? This v2 code prints 'None':
import types
def get_type_name(target_type):
for t in dir(types):
if target_type == getattr(types, t):
return t
class C(object):
pass
c = C()
print get_type_name(type(c)) |
|
Date |
User |
Action |
Args |
2010-03-22 23:38:03 | ericp | set | recipients:
+ ericp, loewis |
2010-03-22 23:38:03 | ericp | set | messageid: <1269301083.71.0.810116535759.issue8206@psf.upfronthosting.co.za> |
2010-03-22 23:38:02 | ericp | link | issue8206 messages |
2010-03-22 23:38:02 | ericp | create | |
|