wx.TheBrushList (and other wx.The...) types

Hi All,

I am taking a closer examination of some of the wxPython objects (the reason will be clear in a few days), and I stumbled across wx.TheBrushList (and other wx.The…) “classes”.

While trying to inspect what kind of object these things are, I found out that the “inspect” module doesn’t know what they are and I am not good enough at Python to find a way to describe them by code.

Please consider this example:

import wx

import inspect

import types

my_object = wx.TheBrushList

string_object = “wx.TheBrushList”

print “\n\nWhat the hell %s is?\n\n”%string_object

for method in dir(inspect):

if method.startswith("is"):

    exec_method = getattr(inspect, method)

    print "%-25s %s"%(method, exec_method(my_object))

result = isinstance(my_object, (type, types.ClassType))

print “%-25s %s\n\n”%(“istype or isclasstype”, result)

This prints the following:

What the hell wx.TheBrushList is?

isbuiltin False

isclass False

iscode False

isdatadescriptor False

isframe False

isfunction False

isgetsetdescriptor False

ismemberdescriptor False

ismethod False

ismethoddescriptor False

ismodule False

isroutine False

istraceback False

istype or isclasstype False

What am I missing? How can I find out what these objects are (via inspect or other means)?

Thank you in advance for your suggestions.

Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://xoomer.alice.it/infinity77/

import PyQt4.QtGui

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named PyQt4.QtGui

import pygtk

Traceback (most recent call last):

File “”, line 1, in

ImportError: No module named pygtk

···

import wx

Hi,

Hi All,
I am taking a closer examination of some of the wxPython objects (the
reason will be clear in a few days), and I stumbled across wx.TheBrushList
(and other wx.The...) "classes".
While trying to inspect what kind of object these things are, I found out
that the "inspect" module doesn't know what they are and I am not good
enough at Python to find a way to describe them by code.

<snip>

What am I missing? How can I find out what these objects are (via inspect or
other means)?
Thank you in advance for your suggestions.

All the 'TheFoo' objects are singleton __instances__ of classes.

inspect.isclass returns False because the object is not a class it is
an instance of a class.

i.e)

inspect.isclass(wx.TheBrushList) == False
inspect.isclass(wx.BrushList) == True

One idea may be to inspect the __class__ attribute to see if it is a
'type' or a 'class', an instance of an object will have a class value
while a class it self will have a value of type.

Example:

class Foo(object):
    pass

print Foo.__class__
<type 'type'>
f = Foo()
print f.__class__
<class 'Foo'>

Regards,

Cody

···

On Thu, Oct 6, 2011 at 10:01 AM, Andrea Gavana <andrea.gavana@gmail.com> wrote: