GHZ <[EMAIL PROTECTED]> writes:

> I would like to say something like:
>
> for filename in os.listdir(DIR) if filename[-4:] == '.xml':
>     <do something>
>
>
> instead of having to say:
>
> for filename in os.listdir(DIR):
>     if filename[-4:] == '.xml':
>         <do something>

If the reason you don't like this one is the extra indentation, one
possibility is

for filename in os.listdir(DIR):
    if filename[-4:] != '.xml':
        continue
    <do something>

-M-
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to