install itertools
sudo pip3 install more-itertools# itertools.tee(iterable, n=2)
# Return n independent iterators from a single iterable.
# The following Python code helps explain what tee does
# (although the actual implementation is more complex
# and uses only a single underlying FIFO queue).
# Roughly equivalent to:
def tee(iterable, n=2):
it = iter(iterable)
deques = [collections.deque() for i in range(n)]
def gen(mydeque):
while True:
if not mydeque: # when the local deque is empty
try:
newval = next(it) # fetch a new value and
except StopIteration:
return
for d in deques: # load it to all the deques
d.append(newval)
yield mydeque.popleft()
return tuple(gen(d) for d in deques)
# Python code to demonstrate the working of
# dropwhile()
# Function to be passed
# as an argument
def is_positive(n):
return n > 0
value_list =[5, 6, -8, -4, 2]
result = list(itertools.dropwhile(is_positive, value_list))
print(result)
Also in Shell:
- linux generate file
- how to import microsoft.online sharepoint powershell
- how to insert a delimiter into an array powershell
- install angular on mac
- install ifconfig on ubuntu
- error: eaccess: permission denied ionic
- set remote url git
- powershell sharepoint copy file to other site collection
- lumen
- how to revert back to previous commit in git
- ubuntu zip file
- firewalld not running centos 7
- remove file from stage git
- git remove all pdf files
- how to convert ts to mp4 with ffmpeg
- install node mac
- shell hide tab
- use a specific version of node
- update yarn
- de shell script with administrative priverlages
- wget git bash
- how to uninstall in ubuntu
- powershell get arguments
- golang compile with injected variable