GNU Info

Info Node: (python2.1-lib.info)new

(python2.1-lib.info)new


Next: site Prev: repr Up: Python Runtime Services
Enter node , (file) or (file)node

Creation of runtime internal objects
====================================

This manual section was written by Moshe Zadka
<moshez@zadka.site.co.il>.
Interface to the creation of runtime implementation objects.

The `new' module allows an interface to the interpreter object creation
functions. This is for use primarily in marshal-type functions, when a
new object needs to be created "magically" and not by using the regular
creation functions. This module provides a low-level interface to the
interpreter, so care must be exercised when using this module.

The `new' module defines the following functions:

`instance(class[, dict])'
     This function creates an instance of CLASS with dictionary DICT
     without calling the `__init__()' constructor.  If DICT is omitted
     or `None', a new, empty dictionary is created for the new
     instance.  Note that there are no guarantees that the object will
     be in a consistent state.

`instancemethod(function, instance, class)'
     This function will return a method object, bound to INSTANCE, or
     unbound if INSTANCE is `None'.  FUNCTION must be callable, and
     INSTANCE must be an instance object or `None'.

`function(code, globals[, name[, argdefs]])'
     Returns a (Python) function with the given code and globals. If
     NAME is given, it must be a string or `None'.  If it is a string,
     the function will have the given name, otherwise the function name
     will be taken from `CODE.co_name'.  If ARGDEFS is given, it must
     be a tuple and will be used to determine the default values of
     parameters.

`code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab)'
     This function is an interface to the `PyCode_New()' C function.

`module(name)'
     This function returns a new module object with name NAME.  NAME
     must be a string.

`classobj(name, baseclasses, dict)'
     This function returns a new class object, with name NAME, derived
     from BASECLASSES (which should be a tuple of classes) and with
     namespace DICT.


automatically generated by info2www version 1.2.2.9