Website hosting service by

 Back to Index

3.27 new -- Creation of runtime internal 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.
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.



2002-2004 Webhosting Service


Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to


Cheap domain registrar provides cheap domain registration, buy domain name and domain transfer from $5.95/year only   Cheap domain registration : Buy domain name and enjoy comprehensive free services