Re: [Tutor] Tweaking list comprehensions

2005-02-14 Thread Alan Gauld
I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachB(files): isHTML = [filename if filename.endswith('.htm') or\

Re: [Tutor] Tweaking list comprehensions

2005-02-14 Thread Alan Gauld
isHTML = [filename if filename.endswith('.htm') or\ filename.endswith(.html') for filename in files] return isHTML No, it should be... Well spotted, but... isHTML = [filename for filename in files if filename.endswith('.htm') or\ filename.endswith('.html') for filename in

[Tutor] Tweaking list comprehensions

2005-02-13 Thread Liam Clarke
Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files: if

Re: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Jacob S.
Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files: if filename.endswith('.htm') or

RE: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Tony Meyer
def approachB(files): isHTML = [filename if filename.endswith('.htm') or\ filename.endswith(.html') for filename in files] return isHTML No, it should be... isHTML = [filename for filename in files if filename.endswith('.htm') or\ filename.endswith('.html') for filename in

Re: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Kent Johnson
Kent Johnson wrote: Liam Clarke wrote: Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files: