| 
									
										
										
										
											1998-08-10 19:42:37 +00:00
										 |  |  | \section{\module{code} --- | 
					
						
							|  |  |  |          Code object services.} | 
					
						
							| 
									
										
										
										
											1998-07-23 17:59:49 +00:00
										 |  |  | \declaremodule{standard}{code} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \modulesynopsis{Code object services.} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-07-18 21:08:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | The \code{code} module defines operations pertaining to Python code | 
					
						
							| 
									
										
										
										
											1999-01-27 15:48:23 +00:00
										 |  |  | objects.  It defines the following function: | 
					
						
							| 
									
										
										
										
											1997-07-18 21:08:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1997-12-29 18:21:37 +00:00
										 |  |  | \begin{funcdesc}{compile_command}{source, \optional{filename\optional{, symbol}}} | 
					
						
							| 
									
										
										
										
											1997-07-18 21:08:07 +00:00
										 |  |  | This function is useful for programs that want to emulate Python's | 
					
						
							|  |  |  | interpreter main loop (a.k.a. the read-eval-print loop).  The tricky | 
					
						
							|  |  |  | part is to determine when the user has entered an incomplete command | 
					
						
							|  |  |  | that can be completed by entering more text (as opposed to a complete | 
					
						
							|  |  |  | command or a syntax error).  This function \emph{almost} always makes | 
					
						
							|  |  |  | the same decision as the real interpreter main loop. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Arguments: \var{source} is the source string; \var{filename} is the | 
					
						
							|  |  |  | optional filename from which source was read, defaulting to | 
					
						
							| 
									
										
										
										
											1999-01-27 15:48:23 +00:00
										 |  |  | \code{'<input>'}; and \var{symbol} is the optional grammar start | 
					
						
							|  |  |  | symbol, which should be either \code{'single'} (the default) or | 
					
						
							|  |  |  | \code{'eval'}. | 
					
						
							| 
									
										
										
										
											1997-07-18 21:08:07 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | Return a code object (the same as \code{compile(\var{source}, | 
					
						
							|  |  |  | \var{filename}, \var{symbol})}) if the command is complete and valid; | 
					
						
							|  |  |  | return \code{None} if the command is incomplete; raise | 
					
						
							| 
									
										
										
										
											1999-01-27 15:48:23 +00:00
										 |  |  | \exception{SyntaxError} if the command is a syntax error. | 
					
						
							| 
									
										
										
										
											1997-07-18 21:08:07 +00:00
										 |  |  | \end{funcdesc} |