File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ exception:
9292
9393An example using only Unix style options:
9494
95+ .. doctest ::
96+ 
9597   >>> import  getopt
9698   >>> args =  ' -a -b -cfoo -d bar a1 a2'  .split() 
9799   >>> args 
@@ -104,6 +106,8 @@ An example using only Unix style options:
104106
105107Using long option names is equally easy:
106108
109+ .. doctest ::
110+ 
107111   >>> s =  ' --condition=foo --testing --output-file abc.def -x a1 a2'  
108112   >>> args =  s.split() 
109113   >>> args 
@@ -115,7 +119,9 @@ Using long option names is equally easy:
115119   >>> args 
116120   ['a1', 'a2'] 
117121
118- In a script, typical usage is something like this::
122+ In a script, typical usage is something like this:
123+ 
124+ .. testcode ::
119125
120126   import getopt, sys
121127
@@ -145,7 +151,9 @@ In a script, typical usage is something like this::
145151       main()
146152
147153Note that an equivalent command line interface could be produced with less code
148- and more informative help and error messages by using the :mod: `argparse ` module::
154+ and more informative help and error messages by using the :mod: `argparse ` module:
155+ 
156+ .. testcode ::
149157
150158   import argparse
151159
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments