>>> import wx
>>> wx.NullBitmap.SubBitmap
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
  File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line 659, in GetSubBitmap
    return _gdi_.Bitmap_GetSubBitmap(*args, **kwargs)
TypeError: Bitmap_GetSubBitmap() takes exactly 2 arguments (1 given)

I didn't call it, I just tried to reference it.
happens with all these methods


well looking at the cpp code behind wxpython's NullBitmap:

//this code is from wxpython's
//_gdi_wrap.cpp    line 7026 to 7124

SWIGINTERN PyObject *_wrap_Bitmap_GetSubBitmap(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
  PyObject *resultobj = 0;
  wxBitmap *arg1 = (wxBitmap *) 0 ;
  wxRect *arg2 = 0 ;
  SwigValueWrapper<wxBitmap > result;
  void *argp1 = 0 ;
  int res1 = 0 ;
  wxRect temp2 ;
  PyObject * obj0 = 0 ;
  PyObject * obj1 = 0 ;
  char *  kwnames[] = {
    (char *) "self",(char *) "rect", NULL 
  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Bitmap_GetSubBitmap",kwnames,&obj0,&obj1)) SWIG_fail;
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_wxBitmap, 0 |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Bitmap_GetSubBitmap" "', expected argument " "1"" of type '" "wxBitmap const *""'"); 
  arg1 = reinterpret_cast< wxBitmap * >(argp1);
    arg2 = &temp2;
    if ( ! wxRect_helper(obj1, &arg2)) SWIG_fail;
    result = ((wxBitmap const *)arg1)->GetSubBitmap((wxRect const &)*arg2);
    if (PyErr_Occurred()) SWIG_fail;
  resultobj = SWIG_NewPointerObj((new wxBitmap(static_cast< const wxBitmap& >(result))), SWIGTYPE_p_wxBitmap, SWIG_POINTER_OWN |  0 );
  return resultobj;
  return NULL;

apparently referencing wx.NullBitmap.SubBitmap calls the "get" code shown in the compiled version of the .cpp code above, which also calls GetSubBitmap, which is what needs the arguments, raising the exception.
I'm not sure though, might need vegaseat to interpret the code.

So even if you just reference it like this: print wx.NullBitmap.SubBitmap You are also calling all that code above.

To put it in much simpler terms, I'll use IronPython as an example.

Let's say I write this C# code:

using System;

namespace PickANumber
    public class Picker
        private static int _thenumber()
            return 10;  //really silly code
        public static int number
                return _thenumber();  //this calls the method above!

and compile it as PickANumber.dll

and I do this in IronPython,
with the previous dll in the same directory:

import clr  #this is in order to use the C# dll
#This example is close to how python interacts with
#compiled C++ in wx!
clr.AddReference("PickANumber")  #.dll is not needed

from PickANumber import Picker  #import the Picker class written in C# above.

raw_input("Pick a number between 1 and 10:  ")
print "The number was", Picker.number  # <-- Actually calls Picker._thenumber() internally!!

Even though it looks like I am referencing "Picker.number", by referencing it, it calls (internally from the dll) the il code return _thenumber(); which definitely is calling a method.

The reason for the error when you "referenced" the wx.NullBitmap.SubBitmap, it called the compiled version of the C++ Bitmap_GetSubBitmap "function", of course missing the required arguments, thereby raising the error.

I think (not entirely sure) that is what is going on.
Hopefully that made sense.

that makes sense... Is there any simple way to reference the method without any 'calls'?

that makes sense... Is there any simple way to reference the method without any 'calls'?

I don't know.
I know you can do this though,
not sure if it is the same:

>>> import wx
>>> wx.NullBitmap.GetSubBitmap
<bound method Bitmap.GetSubBitmap of <wx._gdi.Bitmap; proxy of <Swig Object of type 'wxBitmap *' at 0x2217690> >>

SubBitmap is a property

>>> wx._gdi.Bitmap.SubBitmap
<property object at 0x1700db8>

The function called is

>>> wx._gdi.Bitmap.SubBitmap.fget
<function GetSubBitmap at 0x17ae500>

It's also the 'im_func' of this method

>>> wx._gdi.Bitmap.GetSubBitmap
<unbound method Bitmap.GetSubBitmap>
>>> _.im_func
<function GetSubBitmap at 0x17ae500>