This is a very simple module designed to allow python map/filter functions to be chained together.
The iterable that would normally be the second argument to map is instead passed as an argument to the Stream constructor. The Stream constructor then has methods for filter/map that take only the function and return a new Stream object for further functions to be called.
Usage:
pythonfrom pystream import Streamclass sec:def __init__(self, secType, identifier, maturity):self.secType = secTypeself.identifier = identifierself.maturity = maturityinventory = (sec("CORP", "ABCD", "2022"),sec("MMKT", "ABCE", "2083"),sec("MMKT", "ABCF", "2029"),sec("MUNI", "ABCJ", "1995"))def isLive(s):return int(s.maturity) <= 2023def toString(s):return s.maturity + ":" + s.identifier + ":" + s.maturitydef clomp(s1, s2):return s1 + "||" + s2liveItems = Stream(inventory).filter(isLive).map(toString)print (list(liveItems))