[Python-checkins] r51493 - peps/trunk/pep-0362.txt
brett.cannon
python-checkins at python.org
Wed Aug 23 00:03:11 CEST 2006
Author: brett.cannon
Date: Wed Aug 23 00:03:11 2006
New Revision: 51493
Modified:
peps/trunk/pep-0362.txt
Log:
Point to prototype implementation. Also clarify 'name' attribute on Signature
is not fully qualified.
Modified: peps/trunk/pep-0362.txt
==============================================================================
--- peps/trunk/pep-0362.txt (original)
+++ peps/trunk/pep-0362.txt Wed Aug 23 00:03:11 2006
@@ -15,12 +15,13 @@
========
Python has always supported powerful introspection capabilities,
-including that for functions. Taking a function object, you can fully
-reconstruct the function signature using ``func_defaults``,
-``func_code.co_argcount``, ``func_code.co_flags``, and
-``func_code.co_varnames``. Unfortunately this is a little unruly
-having to look at four different attributes to pull together complete
-information for a function's signature.
+including that for functions and methods (for the rest of this PEP the
+word "function" refers to both functions and methods). Taking a
+function object, you can fully reconstruct the function signature
+using ``func_defaults``, ``func_code.co_argcount``,
+``func_code.co_flags``, and ``func_code.co_varnames``. Unfortunately
+this is a little unruly having to look at four different attributes
+to pull together complete information for a function's signature.
This PEP proposes an object representation for function signatures.
This should help facilitate introspection on functions. It also helps
@@ -40,7 +41,12 @@
A Signature object has the following structure attributes:
* name:str
- Name of the function.
+ Name of the function. This is not fully qualified because
+ function objects for methods do not know the class they are
+ contained within. This makes functions and methods
+ indistinguishable from one another when passed to decorators,
+ prevventing proper creation of a fully qualified name.
+ indistinguishable from
* var_args:str
Name of the ``*args`` parameter, if present, else the empty
string.
@@ -94,11 +100,12 @@
Implementation
==============
-An implementation is forthcoming for experimentation purposes based on
-the 'inspect' module [#inspect-module]_. The classes will be exposed
-in the 'inspect' module as well. This PEP has been posted without
-implementation so as to not be a hinderance to another PEP that is
-under development by another author.
+An implementation can be found in patch #1544909 [#impl]_. It
+modifies the 'inspect' module [#inspect-module]_to include the
+implementation. There is a function named ``getsignature()`` which
+returns the value stored on the ``__signature__`` attribute (for
+methods this is stored directly on the im_func function object since
+that is what decorators will work with).
Relation With Other PEPs
@@ -144,6 +151,9 @@
.. [#pep-3102] Keyword-Only Arguments
(http://www.python.org/dev/peps/pep-3102/)
+.. [#impl] Implementation of PEP 362
+ (http://www.python.org/sf/1544909)
+
Copyright
=========
More information about the Python-checkins
mailing list