Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityTestMu AI Review: How AI is Solving the Quality Engineering Problem(23.09.2026 um 13:18 Uhr)
••
Windows Tipps & SecurityAmazon haut den kabellosen Dyson V8 Stabstaubsauger zum Tiefstpreis raus(24.09.2026 um 09:32 Uhr)
•
Windows Tipps & SecurityUpdates beheben etliche Schwachstellen in Foxit PDF Reader(24.09.2026 um 09:44 Uhr)
••••••
Windows Tipps & Security„Vom Experience Center zum monumentalen Signage-Projekt“(24.09.2026 um 10:30 Uhr)
•
Windows Tipps & SecurityTestMu AI Review: How AI is Solving the Quality Engineering Problem(23.09.2026 um 13:18 Uhr)
••
Windows Tipps & SecurityAmazon haut den kabellosen Dyson V8 Stabstaubsauger zum Tiefstpreis raus(24.09.2026 um 09:32 Uhr)
•
Windows Tipps & SecurityUpdates beheben etliche Schwachstellen in Foxit PDF Reader(24.09.2026 um 09:44 Uhr)
••••••
Windows Tipps & Security„Vom Experience Center zum monumentalen Signage-Projekt“(24.09.2026 um 10:30 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

Why Python's `is` Keyword Will Betray You If You Trust It for Equality

This is one of the most commonly misused Python features and it fails silently, which makes it especially dangerous in production code. a = "hello" b = "hello" print(a == b) print(a is b) Both print True. Safe, right? Now try…

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

This is one of the most commonly misused Python features and it fails silently, which makes it especially dangerous in production code.




a = "hello"
b = "hello"
print(a == b)
print(a is b)






Both print True. Safe, right?



Now try this:




a = "hello world"
b = "hello world"
print(a == b)
print(a is b)






a == b prints True. a is b might print False.



Same code structure. Different result. Here is exactly why.









What is and == Actually Check



== checks value equality. Do these two objects represent the same value?



is checks identity equality. Are these two names pointing to the exact same object in memory?



Two objects can be equal in value while being completely different objects in memory.









String Interning



Python automatically interns some strings. Interning means Python reuses a single object for multiple names with the same value, rather than creating separate objects.



Short strings that look like valid Python identifiers are automatically interned. Longer strings or strings with spaces are not always interned.




a = "hello"
b = "hello"
print(a is b) # True -- both point to the same interned object

a = "hello world"
b = "hello world"
print(a is b) # False -- two separate objects (implementation dependent)






The behavior for longer strings is implementation dependent and version dependent. You cannot rely on it.









Integer Caching



Python caches integers from -5 to 256. Integers in this range are always the same object regardless of how many names point to them.




a = 100
b = 100
print(a is b) # True -- cached integer, same object

a = 1000
b = 1000
print(a is b) # False -- outside cache range, separate objects









a = 256
b = 256
print(a is b) # True -- last cached integer

a = 257
b = 257
print(a is b) # False -- first uncached integer












The Interview Trap






x = None
y = None
print(x is y) # True -- None is a singleton
print(x == y) # True

x = []
y = []
print(x is y) # False -- two separate empty list objects
print(x == y) # True -- both represent empty lists






The canonical use case for is is checking against None, True, and False. These are singletons in Python. Every None in your program is the same object.




# Correct pattern
if value is None:
handle_missing()

# Incorrect pattern (works by accident, not by design)
if value == None:
handle_missing()






The == version works because NoneType.__eq__ is implemented but using is is the semantically correct choice and is what PEP 8 requires.









The Practical Rule



Use == for value comparison in all application code.

Use is only for checking against None, True, and False.

Never use is to compare strings or integers in application code, even if it works in testing.



Practice identity vs equality problems at PyCodeIt.

SOC Incident Playbook: Vulnerability Remediation & Verification
title: Detect Exploitation - Why Python's `is` Keyword Will Betray You If You Trust It for Equality
id: 731281e4-8451-4b74-96cf-a497323f396f
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Why Python\'s `is` Keyword Will" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Why Python's `is` Keyword Will Betray Yo.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Why Python's `is` Keyword Will Betray You If You Trust It for Equality

Thematisch verwandte Begriffe: Pythons, Keyword, Will, Betray · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

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-97056 | SigNoz versions from v0.98.0 up to (but not including) v0.143.0, when co…
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 TTP ⏱️ 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