[Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.70,2.71

Tim Peters python-dev@python.org
Wed, 13 Dec 2000 15:18:49 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv27480/python/dist/src/objects

Modified Files:
	dictobject.c 
Log Message:
Add long-overdue docstrings to dict methods.


Index: dictobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.70
retrieving revision 2.71
diff -C2 -r2.70 -r2.71
*** dictobject.c	2000/12/13 19:58:25	2.70
--- dictobject.c	2000/12/13 23:18:45	2.71
***************
*** 1231,1246 ****
  }
  
  static PyMethodDef mapp_methods[] = {
! 	{"has_key",	(PyCFunction)dict_has_key,      METH_VARARGS},
! 	{"keys",	(PyCFunction)dict_keys},
! 	{"items",	(PyCFunction)dict_items},
! 	{"values",	(PyCFunction)dict_values},
! 	{"update",	(PyCFunction)dict_update},
! 	{"clear",	(PyCFunction)dict_clear},
! 	{"copy",	(PyCFunction)dict_copy},
! 	{"get",         (PyCFunction)dict_get,          METH_VARARGS},
! 	{"setdefault",  (PyCFunction)dict_setdefault,   METH_VARARGS},
! 	{"popitem",	(PyCFunction)dict_popitem},
! 	{NULL,		NULL}		/* sentinel */
  };
  
--- 1231,1288 ----
  }
  
+ 
+ static char has_key__doc__[] =
+ "D.has_key(k) -> 1 if D has a key k, else 0";
+ 
+ static char get__doc__[] =
+ "D.get(k[,d]) -> D[k] if D.has_key(k), else d.  d defaults to None.";
+ 
+ static char setdefault_doc__[] =
+ "D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if not D.has_key(k)";
+ 
+ static char popitem__doc__[] =
+ "D.popitem() -> (k, v), remove and return some (key, value) pair as a\n\
+ 2-tuple; but raise KeyError if D is empty";
+ 
+ static char keys__doc__[] =
+ "D.keys() -> list of D's keys";
+ 
+ static char items__doc__[] =
+ "D.items() -> list of D's (key, value) pairs, as 2-tuples";
+ 
+ static char values__doc__[] =
+ "D.values() -> list of D's values";
+ 
+ static char update__doc__[] =
+ "D.update(E) -> None.  Update D from E: for k in E.keys(): D[k] = E[k]";
+ 
+ static char clear__doc__[] =
+ "D.clear() -> None.  Remove all items from D.";
+ 
+ static char copy__doc__[] =
+ "D.copy() -> a shallow copy of D";
+ 
  static PyMethodDef mapp_methods[] = {
! 	{"has_key",	(PyCFunction)dict_has_key,      METH_VARARGS,
! 	 has_key__doc__},
! 	{"get",         (PyCFunction)dict_get,          METH_VARARGS,
! 	 get__doc__},
! 	{"setdefault",  (PyCFunction)dict_setdefault,   METH_VARARGS,
! 	 setdefault_doc__},
! 	{"popitem",	(PyCFunction)dict_popitem,	METH_OLDARGS,
! 	 popitem__doc__},
! 	{"keys",	(PyCFunction)dict_keys,		METH_OLDARGS,
! 	keys__doc__},
! 	{"items",	(PyCFunction)dict_items,	METH_OLDARGS,
! 	 items__doc__},
! 	{"values",	(PyCFunction)dict_values,	METH_OLDARGS,
! 	 values__doc__},
! 	{"update",	(PyCFunction)dict_update,	METH_OLDARGS,
! 	 update__doc__},
! 	{"clear",	(PyCFunction)dict_clear,	METH_OLDARGS,
! 	 clear__doc__},
! 	{"copy",	(PyCFunction)dict_copy,		METH_OLDARGS,
! 	 copy__doc__},
! 	{NULL,		NULL}	/* sentinel */
  };