Hi Folks,
 
 
I dont know much about Regular Expressions. But I just want to share my ideas.
 
I was trying to implement error checking code on the date argument:
 
I did this:  
 
import re
# the user should enter date in the format: dd/mm/yyyy
p = re.compile('\d\d/\d\d/\d\d\d\d')
 
m = p.match(date)
 
the function match will return an object of type SRE_Match only if the user has supplied the string in the form of dd/mm/yyyy. If the user tries to supply negative values, then match will return None.
So no hassle of using all those Ifs  and Elifs........
I think REGULAR Expressions can be quite powerful...
 
Regards,
Asrarahmed
--
To HIM you shall return.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to