Bill Burns wrote:
> Maybe take a look at 'endswith':
> 
> Example:
> for filename in zfile.namelist():
>      if filename.endswith('.exe') or filename.endswith('.txt'):
>          # do something with filename

In Python 2.5 endswith() can take a tuple of strings to try:
   if filename.endswith(('.exe', '.txt')):

(The double parentheses create a single, tuple argument instead of 
passing two string arguments.)

And yes, endswith() is case-sensitive; use e.g.
   if filename.lower().endswith(('.exe', '.txt')):

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to