the iteration protocol the generators returned by these functions themselvesas well as that returned by the python flavor of the zip built-in they useproduce results only on demand coding your own zipand map(noneof coursemuch of the magic in the examples shown so far lies in their use of the zip built-in to pair arguments from multiple sequences or iterables our map workalikes are also really emulating the behavior of the python map--they truncate at the length of the shortest argumentand they do not support the notion of padding results when lengths differas map does in python with none argumentc:codec:\python \python map(none[ ][ ][( )( )( )(none )map(none'abc''xyz '[(' '' ')(' '' ')(' '' ')(none' ')(none' ')(none' ')using iteration toolswe can code workalikes that emulate both truncating zip and ' padding map--these turn out to be nearly the same in codezip(seqs and map(noneseqs workalikes def myzip(*seqs)seqs [list(sfor in seqsres [while all(seqs)res append(tuple( pop( for in seqs)return res def mymappad(*seqspad=none)seqs [list(sfor in seqsres [while any(seqs)res append(tuple(( pop( if else padfor in seqs)return res 'abc''xyz print(myzip( )print(mymappad( )print(mymappad( pad= )both of the functions coded here work on any type of iterable objectbecause they run their arguments through the list built-in to force result generation ( files would work as argumentsin addition to sequences like stringsnotice the use of the all and any built-ins here--these return true if all and any items in an iterable are true (or equivalentlynonempty)respectively these built-ins are used to stop looping when any or all of the listified arguments become empty after deletions also note the use of the python keyword-only argumentpadunlike the mapour version will allow any pad object to be specified (if you're using xuse generator functions and expressions