Curious about library inclusion

Antoon Pardon antoon.pardon at vub.be
Thu Oct 10 06:23:46 EDT 2019


I was wondering how likely it would be that piped-iterators like shown in
http://code.activestate.com/recipes/580625-collection-pipeline-in-python/
would make it into a future python version. Once I started using them
(and included some more) I found I really liked working with them. For
instance I used to write the following a lot: for line in some_file: lst
= line.strip().split(':') do_stuff(lst) Now I seem to drift into
writing: for lst in some_file | Strip | Split(':'): do_stuff(lst) Where
Strip and Split are defined as follows:
Strip = Map(methodcaller('strip')) def Split(st): return
Map(methodcaller('split', st)) I also found that Apply can be used as a
decorator, that easily turns an iterator into a piped version. So what
are the odds? -- Antoon.




More information about the Python-list mailing list