2011/5/24 Georg Brandl <g.bra...@gmx.net>: > On 24.05.2011 18:08, benjamin.peterson wrote: >> http://hg.python.org/cpython/rev/8f403199f999 >> changeset: 70331:8f403199f999 >> user: Benjamin Peterson <benja...@python.org> >> date: Tue May 24 11:09:06 2011 -0500 >> summary: >> move specialized dir implementations into __dir__ methods (closes #12166) > >> +static PyMethodDef module_methods[] = { >> + {"__dir__", module_dir, METH_NOARGS, >> + PyDoc_STR("__dir__() -> specialized dir() implementation")}, >> + {0} >> +}; > >> static PyMethodDef type_methods[] = { >> {"mro", (PyCFunction)mro_external, METH_NOARGS, >> PyDoc_STR("mro() -> list\nreturn a type's method resolution order")}, >> @@ -2585,6 +2661,8 @@ >> PyDoc_STR("__instancecheck__() -> check if an object is an instance")}, >> {"__subclasscheck__", type___subclasscheck__, METH_O, >> PyDoc_STR("__subclasscheck__() -> check if a class is a subclass")}, >> + {"__dir__", type_dir, METH_NOARGS, >> + PyDoc_STR("__dir__() -> specialized __dir__ implementation for >> types")}, > >> static PyMethodDef object_methods[] = { >> {"__reduce_ex__", object_reduce_ex, METH_VARARGS, >> PyDoc_STR("helper for pickle")}, >> @@ -3449,6 +3574,8 @@ >> PyDoc_STR("default object formatter")}, >> {"__sizeof__", object_sizeof, METH_NOARGS, >> PyDoc_STR("__sizeof__() -> size of object in memory, in bytes")}, >> + {"__dir__", object_dir, METH_NOARGS, >> + PyDoc_STR("__dir__() -> default dir() implementation")}, > > This is interesting: I though we use "->" to specify the return value (or > its type). __instancecheck__ and __subclasscheck__ set a different > precedent, while __sizeof__ follows.
Yes, I was wondering about that, so I just picked one. :) "->" seems to be better for return values, though, given the resemblance to annotations. -- Regards, Benjamin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com