1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\section{\module{new} ---
							 | 
						
					
						
							
								
									
										
										
										
											2000-10-10 17:03:45 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								         Creation of runtime internal objects}
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\declaremodule{builtin}{new}
							 | 
						
					
						
							
								
									
										
										
										
											2000-12-01 15:25:23 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\sectionauthor{Moshe Zadka}{moshez@zadka.site.co.il}
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\modulesynopsis{Interface to the creation of runtime implementation objects.}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								The \module{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 \module{new} module defines the following functions:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2001-01-28 17:23:05 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{funcdesc}{instance}{class\optional{, dict}}
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:58:02 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								This function creates an instance of \var{class} with dictionary
							 | 
						
					
						
							
								
									
										
										
										
											2001-01-28 17:23:05 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{dict} without calling the \method{__init__()} constructor.  If
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\var{dict} is omitted or \code{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.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{funcdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{funcdesc}{instancemethod}{function, instance, class}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								This function will return a method object, bound to \var{instance}, or
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:15:07 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								unbound if \var{instance} is \code{None}.  \var{function} must be
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								callable, and \var{instance} must be an instance object or
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\code{None}.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{funcdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2000-10-10 22:00:03 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}}
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								Returns a (Python) function with the given code and globals. If
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:15:07 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{name} is given, it must be a string or \code{None}.  If it is a
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								string, the function will have the given name, otherwise the function
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								name will be taken from \code{\var{code}.co_name}.  If
							 | 
						
					
						
							
								
									
										
										
										
											2000-10-10 22:00:03 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{argdefs} is given, it must be a tuple and will be used to
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:15:07 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								determine the default values of parameters.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{funcdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       constants, names, varnames, filename, name, firstlineno,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                       lnotab}
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:15:07 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								This function is an interface to the \cfunction{PyCode_New()} C
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								function.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-29 15:45:09 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								%XXX This is still undocumented!!!!!!!!!!!
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{funcdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{funcdesc}{module}{name}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								This function returns a new module object with name \var{name}.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:15:07 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								\var{name} must be a string.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{funcdesc}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\begin{funcdesc}{classobj}{name, baseclasses, dict}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								This function returns a new class object, with name \var{name}, derived
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								from \var{baseclasses} (which should be a tuple of classes) and with
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 18:15:07 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								namespace \var{dict}.
							 | 
						
					
						
							
								
									
										
										
										
											1999-06-17 15:11:35 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								\end{funcdesc}
							 |