Python's Context Dependent Syntax Soup: 「… in …」 And 「… not in …」
Python has these operators to check if a key exist in hash table or element exist in list:
x in list
x not in list
note that ② is not necessary. It can simply be done with
not (x in list).
not operator has multiple meanings, depending on context. It compounds on syntax complexity. Now,
not in is actually a operator. Having English words acting as operator and not function is bad enough, but now that operator is 2 words, separated by space! So, syntactically, it becomes not distinguishable from statements, or the tens of idiosyncratic syntax of C such as its “for”, “while”.
note that the syntax
… in … is similar to the form
for … in …, and also the list comprehension syntax
[… for … in …]. Each have completely different semantics.
〔➤see What's List Comprehension and Why is It Harmful?〕
this is the state of the affair of syntax soup. When you learn a language, there's little governing principle of what symbol can go where (as in formal language❕), instead, you learn by rote of what symbols or words can go where in what context means what.
‹k› in ‹d› is itself idiotic. Python has a
has_key() method for dictionary, which is in sync with the 20 other methods on dict.
Method syntax is systematic and also informative of its meaning because of the name.
Though, strangely, python decided to deprecate it, and in python 3, it's gone.
〔➤see Python: Dictionary〕
comment at g+ discussion
Soup. Soup. It's All good Soup.
- Lambda in Python 3000
- The Fate of Lambda in Python 3000 and Scheme v300
- Python, Lambda, Guido: is Language Design Just Solving Puzzles?
- From Why Not Ruby to F��� Python, Hello Ruby
- Docstring Convention: Python vs Emacs Lisp
- Why Learn Lisp When There Are Perl ＆ Python
- F��� Python: String Methods, Functions, Slashes and Backslashes
- Python Syntax Problem: Complexity of Comment Syntax and Backslash
- Why Python's Lambda is Broken and Can't be Fixed
- Syntax Design: Python's Indentation vs Nesting
- Python Bitwise Invert Oddity
- Python Scope Complexity, Shallow Copy, Deep Copy, Circular List, and the Garbage Underneath Computer Languages