Gerhard Häring wrote: > * Jim Dukarm[2003-04-04 19:29 -0800]: > >>--- Greg Ward napisal ------- >> >>>I think it would be better to make request.form a custom type rather >>>than a dictionary. Then let's talk about adding missing features. >> >>Can request.form be a subclass of dict? That way, all the basic dict >>features that people have been using with it will still work. [...] > > > You don't need to subclass dict to implement the mapping interface. See > the Python documentation for the mapping (and sequence) interfaces. > > Gerhard I think I'd vote for a regular dictionary, but whose values were string-like objects with a list attribute. Something like: from UserString import UserString class FormValue(UserString): def __init__(self, *many): self.list = many UserString.__init__(self, many[0]) >>> h = FormValue('hello') >>> h 'hello' >>> h.list ('hello',) >>> g = FormValue('goodbye', 'au revoir') >>> g 'goodbye' >>> g.list ('goodbye', 'au revoir') >>> g.list and 'multiple' or 'single' 'multiple' The list attribute returns a tuple, not a list, but who's counting. ;-) I guess you need cgi.FieldStorage instances, not strings, but the pattern should still apply. -- Graham