1919# responsible for its maintenance.
2020#
2121
22- __version__ = "2.3 "
22+ __version__ = "2.4 "
2323
2424
2525# Imports
@@ -718,7 +718,7 @@ def make_file(self, binary=None):
718718# ===============================
719719
720720class FormContentDict (UserDict .UserDict ):
721- """Basic (multiple values per field) form content as dictionary .
721+ """Form content as dictionary with a list of values per field .
722722
723723 form = FormContentDict()
724724
@@ -736,11 +736,11 @@ def __init__(self, environ=os.environ):
736736
737737
738738class SvFormContentDict (FormContentDict ):
739- """Strict single-value expecting form content as dictionary .
739+ """Form content as dictionary expecting a single value per field .
740740
741- IF you only expect a single value for each field, then form[key]
741+ If you only expect a single value for each field, then form[key]
742742 will return that single value. It will raise an IndexError if
743- that expectation is not true. IF you expect a field to have
743+ that expectation is not true. If you expect a field to have
744744 possible multiple values, than you can use form.getlist(key) to
745745 get all of the values. values() and items() are a compromise:
746746 they return single strings where there is a single value, and
@@ -754,47 +754,47 @@ def __getitem__(self, key):
754754 def getlist (self , key ):
755755 return self .dict [key ]
756756 def values (self ):
757- lis = []
758- for each in self .dict .values ():
759- if len ( each ) == 1 :
760- lis .append (each [0 ])
761- else : lis .append (each )
762- return lis
757+ result = []
758+ for value in self .dict .values ():
759+ if len (value ) == 1 :
760+ result .append (value [0 ])
761+ else : result .append (value )
762+ return result
763763 def items (self ):
764- lis = []
765- for key ,value in self .dict .items ():
766- if len (value ) == 1 :
767- lis .append ((key , value [0 ]))
768- else : lis .append ((key , value ))
769- return lis
764+ result = []
765+ for key , value in self .dict .items ():
766+ if len (value ) == 1 :
767+ result .append ((key , value [0 ]))
768+ else : result .append ((key , value ))
769+ return result
770770
771771
772772class InterpFormContentDict (SvFormContentDict ):
773773 """This class is present for backwards compatibility only."""
774- def __getitem__ ( self , key ):
775- v = SvFormContentDict .__getitem__ ( self , key )
776- if v [0 ] in string .digits + '+-.' :
777- try : return string .atoi ( v )
774+ def __getitem__ (self , key ):
775+ v = SvFormContentDict .__getitem__ (self , key )
776+ if v [0 ] in string .digits + '+-.' :
777+ try : return string .atoi (v )
778778 except ValueError :
779- try : return string .atof ( v )
779+ try : return string .atof (v )
780780 except ValueError : pass
781781 return string .strip (v )
782- def values ( self ):
783- lis = []
782+ def values (self ):
783+ result = []
784784 for key in self .keys ():
785785 try :
786- lis .append ( self [key ] )
786+ result .append (self [key ])
787787 except IndexError :
788- lis .append ( self .dict [key ] )
789- return lis
790- def items ( self ):
791- lis = []
788+ result .append (self .dict [key ])
789+ return result
790+ def items (self ):
791+ result = []
792792 for key in self .keys ():
793793 try :
794- lis .append ( (key , self [key ]) )
794+ result .append ((key , self [key ]))
795795 except IndexError :
796- lis .append ( (key , self .dict [key ]) )
797- return lis
796+ result .append ((key , self .dict [key ]))
797+ return result
798798
799799
800800class FormContent (FormContentDict ):
@@ -804,7 +804,7 @@ def values(self, key):
804804 else : return None
805805 def indexed_value (self , key , location ):
806806 if self .dict .has_key (key ):
807- if len (self .dict [key ]) > location :
807+ if len (self .dict [key ]) > location :
808808 return self .dict [key ][location ]
809809 else : return None
810810 else : return None
@@ -836,10 +836,10 @@ def test(environ=os.environ):
836836 sys .stderr = sys .stdout
837837 try :
838838 form = FieldStorage () # Replace with other classes to test those
839- print_form (form )
840- print_environ (environ )
841839 print_directory ()
842840 print_arguments ()
841+ print_form (form )
842+ print_environ (environ )
843843 print_environ_usage ()
844844 def f ():
845845 exec "testing print_exception() -- <I>italics?</I>"
@@ -856,10 +856,10 @@ def g(f=f):
856856 maxlen = 50
857857 try :
858858 form = FieldStorage () # Replace with other classes to test those
859- print_form (form )
860- print_environ (environ )
861859 print_directory ()
862860 print_arguments ()
861+ print_form (form )
862+ print_environ (environ )
863863 except :
864864 print_exception ()
865865
0 commit comments