G
Gre7g Luterman
I suppose I was lulled into complacency by how Python makes so many things
look like classes, but I'm starting to realize that they're not, are they?
I'm writing a C program which handles Python objects in different ways based
on their type. I do a PyInstance_Check(PyObj) to determine if the PyObj is
an instance, but it is returning 0 on a lot of stuff that I thought would be
an instance. So I did the following simple test on three things that look
like instances:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.<class '__main__.b'>
I was relieved that a() returns an instance, but I was surprised that
Exceptions aren't really instances at all. And what's the deal with derving
a class from a standard type like a dictionary? I thought for sure, that
would be an instance, but this shows it is a class?!?
Can anyone explain the last one and/or give me a simple test I can do in C
to determine whether a Python object is "instance-like"?
Many thanks,
Gre7g
look like classes, but I'm starting to realize that they're not, are they?
I'm writing a C program which handles Python objects in different ways based
on their type. I do a PyInstance_Check(PyObj) to determine if the PyObj is
an instance, but it is returning 0 on a lot of stuff that I thought would be
an instance. So I did the following simple test on three things that look
like instances:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.<class '__main__.b'>
I was relieved that a() returns an instance, but I was surprised that
Exceptions aren't really instances at all. And what's the deal with derving
a class from a standard type like a dictionary? I thought for sure, that
would be an instance, but this shows it is a class?!?
Can anyone explain the last one and/or give me a simple test I can do in C
to determine whether a Python object is "instance-like"?
Many thanks,
Gre7g