I'm wrong or Will we fix the ducks limp?
Terry Reedy
tjreedy at udel.edu
Fri Jun 3 22:12:37 EDT 2016
On 6/3/2016 10:20 AM, Sayth Renshaw wrote:
> Very briefly because I hope to shot down eloquently.
>
> Python is beautiful and is supposed to be a duck typed language, Yes?
>
> Then if I create and assign to a new variable with a list action why does the duck not quack?
>
> It feels wrong to spend a line writing what is already obvious
>
> def getsMeet(files=file_list):
> """Get a File or List of Files.
>
> From the list of files determine
> what meetings exist and prepare them
> to be parsed
> """
> pyqFiles = []
> for filename in sorted(file_list):
The parameter name if files, not file_list. The latter is just the default.
> pyqFiles = pyqFiles.append(pq(filename=my_dir + filename))
>
> return pyqFiles
You can replace the body with
return [pq(filename=my_dir+filename) for filename in sorted(files)]
where files is any iterable of file names.
--
Terry Jan Reedy
More information about the Python-list
mailing list