mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-11-25 20:44:24 +01:00
Minor exmpample: Correct explanation
* `'a'[0][0][0][0][0]` is semanically correctly not because strings are iterables but because they are sequences as well. Related to https://github.com/satwikkansal/wtfpython/issues/30
This commit is contained in:
parent
5467a67f0f
commit
24c4a6469e
2
README.md
vendored
2
README.md
vendored
@ -1630,7 +1630,7 @@ a, b = a[b] = {}, 5
|
|||||||
|
|
||||||
* Few weird looking but semantically correct statements:
|
* Few weird looking but semantically correct statements:
|
||||||
+ `[] = ()` is a semantically correct statement (unpacking an empty `tuple` into an empty `list`)
|
+ `[] = ()` is a semantically correct statement (unpacking an empty `tuple` into an empty `list`)
|
||||||
+ `'a'[0][0][0][0][0]` is also a semantically correct statement as strings are iterable in Python.
|
+ `'a'[0][0][0][0][0]` is also a semantically correct statement as strings are [sequences](https://docs.python.org/3/glossary.html#term-sequence)(iterables supporting element access using integer indices) in Python.
|
||||||
+ `3 --0-- 5 == 8` and `--5 == 5` are both semantically correct statements and evaluate to `True`.
|
+ `3 --0-- 5 == 8` and `--5 == 5` are both semantically correct statements and evaluate to `True`.
|
||||||
|
|
||||||
* Given that `a` is a number, `++a` and `--a` are both valid Python statements, but don't behave the same way as compared with similar statements in languages like C, C++ or Java.
|
* Given that `a` is a number, `++a` and `--a` are both valid Python statements, but don't behave the same way as compared with similar statements in languages like C, C++ or Java.
|
||||||
|
Loading…
Reference in New Issue
Block a user