I'm wrong or Will we fix the ducks limp?

Nagy László Zsolt gandalf at shopzeus.com
Fri Jun 3 12:11:12 EDT 2016


> 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):
>          pyqFiles = pyqFiles.append(pq(filename=my_dir + filename))
>
>      return pyqFiles
This may not be the answer you are seeking, but how about:

def getsMeet(files=file_list):
     return [pq(filename=my_dir + filename) for filename in sorted(file_list)]

If you can use any iterable instead of a list, then you can also 
consider using a generator:

def getsMeet(files=file_list):
     for filename in sorted(file_list):
         yield pq(filename=my_dir + filename)

for pg_obj in getsMeet(my_file_list):
     process(pg_obj)

This way you do not need to construct a list at all, and it won't create all pq objects in advance.



More information about the Python-list mailing list