WTF Python: Exploring and understanding Python through surprising snippets
I feel like WTFs caused by doing something <i>deeply weird</i> hardly counts against the language.<p>Yes doing the walrus operator inside brackets works. Yes of course it's going to be doing weird things. Is this really surprising to anyone? It's not what that operator is <i>for</i>.<p>Yes comparing strings with "is" works <i>sometimes</i>. It's not checking equality and it isn't supposed to. In another implementation using "is" might work all the time or none of the time. Don't use "is" to compare strings. it's not what that's for.<p>Yes chaining mismatching operations does weird things. Be clearer in how you write your code. It's no surprise that writing confusing code results in confusing results.<p>I've been seeing a growing anti-python sentiment lately, and most of it seems to be based on these sorts of odd perceived language defects. Python is by no means perfect, but none of the code on this page is something anyone would actually write in production code on purpose.<p>I suppose it's a sign of python getting more popular.