nonlocal in Python 3
#TIL about nonlocal in Python 3 Inner functions can access outer variables but can’t modify them by default Here’s a contrived simple example def outer(): num = 0 def inner(): nonlocal num num += 1 inner() If you remove t...
Final from typing import Final _PI: Final[float] = 3.14 Hashable from typing import Any, Dict from collections.abc import Hashable my_dict: Dict[Hashable, Any] TypedDict # Python >= 3.11 from typing import Optional, NotRequired, TypedDict # Pyth...
Select columns in a terminal eg: select only the pids VSCode terminal : alt/option + click and drag iTerm: ⌘ + alt / ⌥ + click and drag https://www.youtube.com/watch?v=v1Y7aoRnWdA
which is the opposite order for Jestexpect(myVar).toBe(42) assumes the first is expected, second is actual in the error message. self.assertEqual(expected, actual) self.assertEqual(42, my_var) PyCharm even displays Expected and Actual Failure Expect...
PIP_REQUIRE_VIRTUALENV=truein your .zshrc (or env variables) prevents you from pip installing globally so that you only run pip install in a venv Only use pipx for global installs
Problem In VSCode, when I trigger suggestions (with Ctrl space), it would show snippet suggestions at the top Instead of showing me possible parameter options Solution TIL You can move snippet suggestions to the bottom (or inline) so that suggesti...
ESLint can give an error if you leave a console.log or console.error in your codebase. We can do the same with any other function! Example: suppress console const suppressConsoleWarnAndError = () => { const consoleErrorSpy = jest.spyOn(console, 'er...