symbian-qemu-0.9.1-12/python-2.6.1/Doc/library/new.rst
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 
       
     2 :mod:`new` --- Creation of runtime internal objects
       
     3 ===================================================
       
     4 
       
     5 .. module:: new
       
     6    :synopsis: Interface to the creation of runtime implementation objects.
       
     7    :deprecated:
       
     8 
       
     9 .. deprecated:: 2.6
       
    10    The :mod:`new` module has been removed in Python 3.0.
       
    11 
       
    12 .. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
       
    13 
       
    14 
       
    15 The :mod:`new` module allows an interface to the interpreter object creation
       
    16 functions. This is for use primarily in marshal-type functions, when a new
       
    17 object needs to be created "magically" and not by using the regular creation
       
    18 functions. This module provides a low-level interface to the interpreter, so
       
    19 care must be exercised when using this module. It is possible to supply
       
    20 non-sensical arguments which crash the interpreter when the object is used.
       
    21 
       
    22 The :mod:`new` module defines the following functions:
       
    23 
       
    24 
       
    25 .. function:: instance(class[, dict])
       
    26 
       
    27    This function creates an instance of *class* with dictionary *dict* without
       
    28    calling the :meth:`__init__` constructor.  If *dict* is omitted or ``None``, a
       
    29    new, empty dictionary is created for the new instance.  Note that there are no
       
    30    guarantees that the object will be in a consistent state.
       
    31 
       
    32 
       
    33 .. function:: instancemethod(function, instance, class)
       
    34 
       
    35    This function will return a method object, bound to *instance*, or unbound if
       
    36    *instance* is ``None``.  *function* must be callable.
       
    37 
       
    38 
       
    39 .. function:: function(code, globals[, name[, argdefs[, closure]]])
       
    40 
       
    41    Returns a (Python) function with the given code and globals. If *name* is given,
       
    42    it must be a string or ``None``.  If it is a string, the function will have the
       
    43    given name, otherwise the function name will be taken from ``code.co_name``.  If
       
    44    *argdefs* is given, it must be a tuple and will be used to determine the default
       
    45    values of parameters.  If *closure* is given, it must be ``None`` or a tuple of
       
    46    cell objects containing objects to bind to the names in ``code.co_freevars``.
       
    47 
       
    48 
       
    49 .. function:: code(argcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab)
       
    50 
       
    51    This function is an interface to the :cfunc:`PyCode_New` C function.
       
    52 
       
    53    .. XXX This is still undocumented!
       
    54 
       
    55 
       
    56 .. function:: module(name[, doc])
       
    57 
       
    58    This function returns a new module object with name *name*. *name* must be a
       
    59    string. The optional *doc* argument can have any type.
       
    60 
       
    61 
       
    62 .. function:: classobj(name, baseclasses, dict)
       
    63 
       
    64    This function returns a new class object, with name *name*, derived from
       
    65    *baseclasses* (which should be a tuple of classes) and with namespace *dict*.
       
    66