wtfpython
wtfpython copied to clipboard
What the f*ck Python? 😱
``` >>> def __greet(): ... print("hello") ... >>> __greet() hello >>> class C: ... def run(self): ... __greet() ... >>> C().run() Traceback (most recent call last): File "", line 1,...
Since the result of ```py a=[1,0]; a[0],a[a[0]]=0,a[0]; print(a) ``` was unexpected for me, I prepared a section.
Hi Satwik! If you are interested in antediluvian times, check out https://github.com/MarcinCiura/6-gotchas :) Cheers!
It seems that the CLI version with '**pip install wtfpython -U**' no longer works! I got the following error when trying to install wtfpython: ``` Fetching the latest version... Uh...
```py print(3 - - 2) print(3 + + 2) """output 5 5 """ ```
Credit goes to Javier Honduvilla Coto for find this: http://hondu.co/blog/open-and-python I contacted him by email to clarify a few bits, and thought it'd be a nice addition here. ```python f...
### ▶ deepcopy cheats Once you got a list of objects, and you want to make a deep copy of them... ```py from copy import deepcopy x=[] xs = [x]...
Went for a simple design considering its gonna be used on a web-site.
```python var = tuple([ [1, 2, 3], [4, 5, 6] ]) l1, l2 = zip(*sorted(zip(*var))) print(l1, l2) l3 = zip(*sorted(zip(var))) print(l3) print(zip(*sorted(zip(var)))) print(list(zip(*sorted(zip(var))))) ``` - result: ```shell (1, 2, 3)...
The example ```python from typing import Optional class S: pass class A: S: Optional[S] = S() pass if __name__ == '__main__': print("ok?") ``` ``` TypeError: Optional[t] requires a single type....