ASPN ActiveState Programmer Network
  ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups | Web Services
SEARCH

Reference
ActivePython 2.5
Python Documentation
Library Reference
5. Data Types
5.1 datetime -- Basic date and time types
5.2 calendar -- General calendar-related functions
5.3 collections -- High-performance container datatypes
5.4 heapq -- Heap queue algorithm
5.5 bisect -- Array bisection algorithm
5.6 array -- Efficient arrays of numeric values
5.7 sets -- Unordered collections of unique elements
5.8 sched -- Event scheduler
5.9 mutex -- Mutual exclusion support
5.10 Queue -- A synchronized queue class
5.11 weakref -- Weak references
5.12 UserDict -- Class wrapper for dictionary objects
5.13 UserList -- Class wrapper for list objects
5.14 UserString -- Class wrapper for string objects
5.15 types -- Names for built-in types
5.16 new -- Creation of runtime internal objects
5.17 copy -- Shallow and deep copy operations
5.18 pprint -- Data pretty printer
5.19 repr -- Alternate repr() implementation

MyASPN >> Reference >> ActivePython 2.5 >> Python Documentation >> Library Reference >> 5. Data Types
ActivePython 2.5 documentation

5.16 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. It is possible to supply non-sensical arguments which crash the interpreter when the object is used.

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[, closure]]])
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. If closure is given, it must be None or a tuple of cell objects containing objects to bind to the names in code.co_freevars.

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[, doc])
This function returns a new module object with name name. name must be a string. The optional doc argument can have any type.

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.
See About this document... for information on suggesting changes.

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState 2004 All rights reserved