Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Web Security TippsIntroducing the new Confluence integration with Google Chat(22.09.2026 um 19:40 Uhr)
Web Security TippsQuick notes in Take notes for me(22.09.2026 um 21:31 Uhr)
Sichere ProgrammierungSecurity improvements for SSH(22.09.2026 um 16:11 Uhr)
Sichere ProgrammierungKI-Akzeptanz: Wie Rewe digital einfach nur den Chatbot umbenannte(22.09.2026 um 18:00 Uhr)
Sichere ProgrammierungClaude Opus 5.5: Keeping safety ahead of capabilities(22.09.2026 um 20:59 Uhr)
Sichere ProgrammierungYour Terraform Monolith Isn't Too Big. It's Tightly Coupled.(22.09.2026 um 21:00 Uhr)
Sichere ProgrammierungMy PR got merged into Mike — OSS Legal AI Platform 🎉(22.09.2026 um 21:34 Uhr)
Sichere ProgrammierungStop Writing JavaScript To Fix `100vh` On Mobile(22.09.2026 um 21:35 Uhr)
Sichere ProgrammierungNext.js proxy.ts Explained (with Cheat Sheet)(22.09.2026 um 21:36 Uhr)
Web Security TippsIntroducing the new Confluence integration with Google Chat(22.09.2026 um 19:40 Uhr)
Web Security TippsQuick notes in Take notes for me(22.09.2026 um 21:31 Uhr)
Sichere ProgrammierungSecurity improvements for SSH(22.09.2026 um 16:11 Uhr)
Sichere ProgrammierungKI-Akzeptanz: Wie Rewe digital einfach nur den Chatbot umbenannte(22.09.2026 um 18:00 Uhr)
Sichere ProgrammierungClaude Opus 5.5: Keeping safety ahead of capabilities(22.09.2026 um 20:59 Uhr)
Sichere ProgrammierungYour Terraform Monolith Isn't Too Big. It's Tightly Coupled.(22.09.2026 um 21:00 Uhr)
Sichere ProgrammierungMy PR got merged into Mike — OSS Legal AI Platform 🎉(22.09.2026 um 21:34 Uhr)
Sichere ProgrammierungStop Writing JavaScript To Fix `100vh` On Mobile(22.09.2026 um 21:35 Uhr)
Sichere ProgrammierungNext.js proxy.ts Explained (with Cheat Sheet)(22.09.2026 um 21:36 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

itertools in Python (8)

Buy Me a Coffee☕ *Memo: My post explains itertools about count(), cycle() and repeat(). starmap() can return the iterator which does function with the elements of iterable one by one to returns the result one by one as shown b…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Buy Me a Coffee



*Memo:





starmap() can return the iterator which does function with the elements of iterable one by one to returns the result one by one as shown below:



*Memo:




  • The 1st argument is function(Required-Type:Callable):


    • Don't use function=.






  • The 2nd argument is iterable(Required-Type:Iterable):


    • Don't use iterable=.









from itertools import starmap

x = starmap(lambda: None, [])

print(x)
# <itertools.starmap object at 0x000001BE9A289CF0>

print(next(x))
# StopIteration:









from itertools import starmap
from operator import add

x = starmap(lambda a, b: a+b, [(2, 5), (3, 2), (10, 3)])
x = starmap(add, [(2, 5), (3, 2), (10, 3)])

print(next(x)) # 7
print(next(x)) # 5
print(next(x)) # 13
print(next(x)) # StopIteration:









from itertools import starmap
from operator import mul

for x in starmap(lambda a, b: a*b, [(2, 5), (3, 2), (10, 3)]):
# for x in starmap(mul, [(2, 5), (3, 2), (10, 3)]):
print(x)
# 10
# 6
# 30









from itertools import starmap

for x in starmap(lambda a, b: a**b, [(2, 5), (3, 2), (10, 3)]):
# for x in starmap(pow, [(2, 5), (3, 2), (10, 3)]):
print(x)
# 32
# 9
# 1000






tee() can return a tuple of the iterators which each return the elements of iterable one by one as shown below:



*Memo:




  • The 1st argument is iterable(Required-Type:Iterable):


    • Don't use iterable=.






  • The 2nd argument is n(Optional-Default:2-Type:int):


    • It's the number of iterators.

    • It must be 0 <= x.

    • Don't use n=.









from itertools import tee

v = tee('ABC')
v = tee('ABC', 2)
v = tee(['A', 'B', 'C'])

print(v)
# (<itertools._tee object at 0x000001BE99D6E3C0>,
# <itertools._tee object at 0x000001BE99F85440>)

print(next(v[0])) # A
print(next(v[0])) # B
print(next(v[0])) # C
print(next(v[1])) # A
print(next(v[1])) # B
print(next(v[1])) # C

print(next(v[0])) # StopIteration:
print(next(v[1])) # StopIteration:









from itertools import tee

for x in tee('ABC'):
# for x in tee(['A', 'B', 'C']):
for y in x:
print(y)
# A
# B
# C
# A
# B
# C









from itertools import tee

for x in tee('ABC', 3):
# for x in tee(['A', 'B', 'C'], 3):
for y in x:
print(y)
# A
# B
# C
# A
# B
# C
# A
# B
# C






zip_longest() can return the iterator which aggregates the elements of *iterables one by one to returns a tuple of one or more elements one by one as shown below:



*Memo:




  • The 1st arguments are *iterables(Optional-Default:()-Type:Iterable):


    • Don't use any keywords like *iterables=, iterables=, etc.






  • The 2nd argument is fillvalue(Optional-Default:None-Type:Any or NoneType):


    • It's the value to fill the zero or more missing elements of a returned tuple.


    • fillvalue= must be used.









from itertools import zip_longest

v = zip_longest()
v = zip_longest((), fillvalue=None)

print(v)
# <itertools.zip_longest object at 0x000001BE99F29FD0>

print(next(v))
# StopIteration:









from itertools import zip_longest

v = zip_longest('ABC')
v = zip_longest(['A', 'B', 'C'])

print(next(v)) # ('A',)
print(next(v)) # ('B',)
print(next(v)) # ('C',)
print(next(v)) # StopIteration:









from itertools import zip_longest

v = zip_longest('ABC', 'vwxyz')
v = zip_longest(['A', 'B', 'C'], ['v', 'w', 'x', 'y', 'z'])

print(next(v)) # ('A', 'v')
print(next(v)) # ('B', 'w')
print(next(v)) # ('C', 'x')
print(next(v)) # (None, 'y')
print(next(v)) # (None, 'z')
print(next(v)) # StopIteration:









from itertools import zip_longest

v = zip_longest('ABC', 'vwxyz', fillvalue='Abscent')
v = zip_longest(['A', 'B', 'C'], ['v', 'w', 'x', 'y', 'z'],
fillvalue='Abscent')

print(next(v)) # ('A', 'v')
print(next(v)) # ('B', 'w')
print(next(v)) # ('C', 'x')
print(next(v)) # ('Abscent', 'y')
print(next(v)) # ('Abscent', 'z')
print(next(v)) # StopIteration:









from itertools import zip_longest

for x in zip_longest('ABC', 'vwxyz', [10, 20], fillvalue='Abscent'):
# for x in zip_longest(['A', 'B', 'C'], ['v', 'w', 'x', 'y', 'z'],
# [10, 20], fillvalue='Abscent'):
print(x)
# ('A', 'v', 10)
# ('B', 'w', 20)
# ('C', 'x', 'Abscent')
# ('Abscent', 'y', 'Abscent')
# ('Abscent', 'z', 'Abscent')









from itertools import zip_longest

for x in zip_longest('ABC', 'vwxyz', [10, 20], fillvalue='Abscent'):
# for x in zip_longest(['A', 'B', 'C'], ['v', 'w', 'x', 'y', 'z'],
# [10, 20], fillvalue='Abscent'):
for y in x:
print(y)
# A
# v
# 10
# B
# w
# 20
# C
# x
# Abscent
# Abscent
# y
# Abscent
# Abscent
# z
# Abscent


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten itertools in Python (8)

Thematisch verwandte Begriffe: itertools, Python · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-77259 | MCP Atlassian is a Model Context Protocol (MCP) server for Atlassian pro…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick