source: trunk/essentials/dev-lang/python/Doc/lib/libnew.tex

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 2.7 KB
Line 
1\section{\module{new} ---
2 Creation of runtime internal objects}
3
4\declaremodule{builtin}{new}
5\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
6\modulesynopsis{Interface to the creation of runtime implementation objects.}
7
8
9The \module{new} module allows an interface to the interpreter object
10creation functions. This is for use primarily in marshal-type functions,
11when a new object needs to be created ``magically'' and not by using the
12regular creation functions. This module provides a low-level interface
13to the interpreter, so care must be exercised when using this module.
14It is possible to supply non-sensical arguments which crash the
15interpreter when the object is used.
16
17The \module{new} module defines the following functions:
18
19\begin{funcdesc}{instance}{class\optional{, dict}}
20This function creates an instance of \var{class} with dictionary
21\var{dict} without calling the \method{__init__()} constructor. If
22\var{dict} is omitted or \code{None}, a new, empty dictionary is
23created for the new instance. Note that there are no guarantees that
24the object will be in a consistent state.
25\end{funcdesc}
26
27\begin{funcdesc}{instancemethod}{function, instance, class}
28This function will return a method object, bound to \var{instance}, or
29unbound if \var{instance} is \code{None}. \var{function} must be
30callable.
31\end{funcdesc}
32
33\begin{funcdesc}{function}{code, globals\optional{, name\optional{,
34 argdefs\optional{, closure}}}}
35Returns a (Python) function with the given code and globals. If
36\var{name} is given, it must be a string or \code{None}. If it is a
37string, the function will have the given name, otherwise the function
38name will be taken from \code{\var{code}.co_name}. If
39\var{argdefs} is given, it must be a tuple and will be used to
40determine the default values of parameters. If \var{closure} is given,
41it must be \code{None} or a tuple of cell objects containing objects
42to bind to the names in \code{\var{code}.co_freevars}.
43\end{funcdesc}
44
45\begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,
46 constants, names, varnames, filename, name, firstlineno,
47 lnotab}
48This function is an interface to the \cfunction{PyCode_New()} C
49function.
50%XXX This is still undocumented!!!!!!!!!!!
51\end{funcdesc}
52
53\begin{funcdesc}{module}{name[, doc]}
54This function returns a new module object with name \var{name}.
55\var{name} must be a string.
56The optional \var{doc} argument can have any type.
57\end{funcdesc}
58
59\begin{funcdesc}{classobj}{name, baseclasses, dict}
60This function returns a new class object, with name \var{name}, derived
61from \var{baseclasses} (which should be a tuple of classes) and with
62namespace \var{dict}.
63\end{funcdesc}
Note: See TracBrowser for help on using the repository browser.