[Tutor] optional parameter in list comprehension

bob gailer bgailer at gmail.com
Mon Dec 29 16:56:20 CET 2008


Dj Gilcrease wrote:
> def myfiles(directory,extension=None):
>     for x in [os.path.join(x,i) for x,y,z in os.walk(directory)\
>     if extension: << SYNTAX ERROR!
>         for i in z if i.endswith(extension)]:print x
>
>   

-- 
Bob Gailer
Chapel Hill NC 
919-636-4239



More information about the Tutor mailing list