[Python-checkins] r43564 - in python/trunk: Doc/lib/libfuncs.tex Misc/NEWS Python/bltinmodule.c (original) (raw)

neal.norwitz python-checkins at python.org
Mon Apr 3 06:48:38 CEST 2006


Author: neal.norwitz Date: Mon Apr 3 06:48:37 2006 New Revision: 43564

Modified: python/trunk/Doc/lib/libfuncs.tex python/trunk/Misc/NEWS python/trunk/Python/bltinmodule.c Log: Accept keyword arguments for import and doc the addition of the level param from PEP 328.

Modified: python/trunk/Doc/lib/libfuncs.tex

--- python/trunk/Doc/lib/libfuncs.tex (original) +++ python/trunk/Doc/lib/libfuncs.tex Mon Apr 3 06:48:37 2006 @@ -6,7 +6,7 @@

\setindexsubitem{(built-in function)}

-\begin{funcdesc}{import}{name\optional{, globals\optional{, locals\optional{, fromlist}}}} +\begin{funcdesc}{import}{name\optional{, globals\optional{, locals\optional{, fromlist\optional{, level}}}}} This function is invoked by the \keyword{import}\stindex{import} statement. It mainly exists so that you can replace it with another function that has a compatible interface, in order to change the @@ -20,9 +20,9 @@

For example, the statement \samp{import spam} results in the following call: \code{import('spam',} \code{globals(),}

\begin{funcdesc}{abs}{x}

Modified: python/trunk/Misc/NEWS

--- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Apr 3 06:48:37 2006 @@ -12,6 +12,8 @@ Core and builtins

+- import accepts keyword arguments. +

Modified: python/trunk/Python/bltinmodule.c

--- python/trunk/Python/bltinmodule.c (original) +++ python/trunk/Python/bltinmodule.c Mon Apr 3 06:48:37 2006 @@ -31,23 +31,25 @@ static PyObject *filtertuple (PyObject *, PyObject *);

static PyObject * -builtin___import__(PyObject *self, PyObject *args) +builtin___import__(PyObject *self, PyObject *args, PyObject *kwds) { + static char *kwlist[] = {"name", "globals", "locals", "fromlist", + "level", 0}; char *name; PyObject *globals = NULL; PyObject *locals = NULL; PyObject *fromlist = NULL; int level = -1;

-"import(name, globals, locals, fromlist) -> module\n
+"import(name, globals={}, locals={}, fromlist=[], level=-1) -> module\n
\n
Import a module. The globals are only used to determine the context;\n
they are not modified. The locals are currently unused. The fromlist\n
@@ -55,7 +57,10 @@ empty list to emulate ``import name''.\n
When importing a module from a package, note that import('A.B', ...)\n
returns package A when fromlist is empty, but its submodule B when\n
-fromlist is not empty."); +fromlist is not empty. Level is used to determine whether to perform \n
+absolute or relative imports. -1 is the original strategy of attempting\n
+both absolute and relative imports, 0 is absolute, a positive number\n
+is the number of parent directories to search relative to the current module.");

static PyObject * @@ -2210,7 +2215,7 @@

static PyMethodDef builtin_methods[] = {



More information about the Python-checkins mailing list