Re: scanning for numerals / letters

2006-04-19 Thread Gerard Flanagan
Kun wrote: > I have the following if statement that checks if a form is empty: > > if form.has_key("date") and form["date"].value != "": > date=form['date'].value > > else: > print "ERROR: No date entered!" > raise Exception > > I would also like to add another

Re: scanning for numerals / letters

2006-04-19 Thread johnzenger
First, note that form["date"] is all you need. form["date"].value is redundant. I would do this with sets: import string if set(form["date"]) & set(string.ascii_letters) != set([]): print "You have to enter a date with numbers" if set(form["purchases"]) & set(string.digits) != set([]): print "P

Re: scanning for numerals / letters

2006-04-18 Thread Dale Strickland-Clark
What about this? import re if not form.get('date'): print "Tsk! No date entered." raise Exception if re.search('[a-zA-Z]', form.get('date')): print "Tsk! No fancy date words." raise Exception date = form.get('date') if not form.get('purchases'): print "Ts

Re: scanning for numerals / letters

2006-04-18 Thread Steve Bergman
Something like this should work: == for c in form.get('date'): if c in string.letters: print "ERROR: You have to enter a date with numbers." == You have to import the string module. 'letters' is one of the attributes defined in that module. Other attributes