Like life itself, we seem to want more control. And this next function we'll create will give us just that -- and output a warning if the field wasn't filled in correctly!
Since this is pretty similar to our other function, I'm just going to skip over it quickly. If you've ever used Perl, then you've spotted the regular expressions hiding in there. Regular expressions in Python are accessed though the 're' module (Python's regular expression library), for obvious reasons... regular expressions still seem like the best way to describe and check form values. If you want to find out more about regular expressions and Python check out the 're' module at http://www.python.org/doc/2.3.3/lib/module-re.html Then if the value isn't what we want, we get a warning instead of just ignoring the field. Anyone wondering what **fields is all about? I'm sure someone is. The simplest explanation I can think of is that it tells the function to expect a variable number of arguments in X format (currying in functional programming) i.e.:
Simple, and very useful form time to time! Time for a cookie break... No, not the food... although, still pretty sweet over all.
blog comments powered by Disqus |