File tree Expand file tree Collapse file tree 1 file changed +19
-20
lines changed Expand file tree Collapse file tree 1 file changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -486,31 +486,30 @@ or use it incrementally::
486486    from textwrap import dedent 
487487    from concurrent import interpreters 
488488
489-     if __name__ == '__main__': 
490-         interp = interpreters.create() 
489+     interp = interpreters.create() 
491490
492-          # Prepare the interpreter. 
493-          interp.exec(dedent(""" 
494-              # We will need this later. 
495-              import math 
491+     # Prepare the interpreter. 
492+     interp.exec(dedent(""" 
493+         # We will need this later. 
494+         import math 
496495
497-              # Initialize the value. 
498-              value = 1 
496+         # Initialize the value. 
497+         value = 1 
499498
500-              def double(val): 
501-                  return val + val 
502-              """)) 
499+         def double(val): 
500+             return val + val 
501+         """)) 
503502
504-          # Do the work. 
505-          for _ in range(9): 
506-              interp.exec(dedent(""" 
507-                  assert math.factorial(value + 1) >= double(value) 
508-                  value = double(value) 
509-                  """)) 
503+     # Do the work. 
504+     for _ in range(9): 
505+         interp.exec(dedent(""" 
506+             assert math.factorial(value + 1) >= double(value) 
507+             value = double(value) 
508+             """)) 
510509
511-          # Show the result. 
512-          interp.exec('print(value)') 
513-          # prints: 1024 
510+     # Show the result. 
511+     interp.exec('print(value)') 
512+     # prints: 1024 
514513
515514In case you're curious, in a little while we'll look at how to pass
516515data in and out of an interpreter (instead of just printing things).
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments