git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


> > 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.

Ok now that is cool and definitely I need to play with that a little more.

Sayth