[Python-checkins] CVS: python/dist/src/Include funcobject.h,2.23,2.23.4.1

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 02 Jul 2001 11:06:08 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv18444/Include

Modified Files:
      Tag: descr-branch
	funcobject.h 
Log Message:
Add a new type: 'classmethod'.  This needs to be fleshed out a bit
more with docstrings and maybe attribute, but it works:

  >>> class C(object):
  ...     def f(*a): return a
  ...     f = classmethod(f)
  ... 
  >>> C.f(1, 2)
  (<type 'C'>, 1, 2)
  >>> C().f(1, 2)
  (<type 'C'>, 1, 2)
  >>> class D(C):
  ...     pass
  ... 
  >>> D.f(1, 2)
  (<type 'D'>, 1, 2)
  >>> D().f(1, 2)
  (<type 'D'>, 1, 2)
  >>> 

It doesn't work in classic classes yet (the method binding there needs
to be updated).



Index: funcobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/funcobject.h,v
retrieving revision 2.23
retrieving revision 2.23.4.1
diff -C2 -r2.23 -r2.23.4.1
*** funcobject.h	2001/03/23 04:17:58	2.23
--- funcobject.h	2001/07/02 18:06:06	2.23.4.1
***************
*** 43,46 ****
--- 43,49 ----
  	(((PyFunctionObject *)func) -> func_closure)
  
+ /* The classmethod type lives here, too */
+ extern DL_IMPORT(PyTypeObject) PyClassMethod_Type;
+ 
  #ifdef __cplusplus
  }