Daily Python Tip 🐍🐧 (@python_tip) header
Daily Python Tip 🐍🐧 (@python_tip) profile picture

One #python tip per day. Do you have any? Send it to https://xitter.twitterapi.xyz/t.co/AIPDodWr5i. Edited by @simecek, @karlafej, and... you?

Joined February 2017
Last week, two versions of litellm package (3.4M downloads/day) contains malicious code due to previous compromise of maintainer's PyPI credentials. This seems as a cool trick to be less vulnerable to such attacks (found on LinkedIn / Hacker news) πŸ‘‡
1
2
19
3,244
Still digesting #EuroPython2024, but #DjangoConEU 2024 videos just appeared on YouTube! youtube.com/playlist?list=PL… My favorites: - AnΕΎe's "Django, SQLite, and Production" youtube.com/watch?v=GTDYwEXv… - @scriptogre's "Functional Chatbots" tutorial (not on YT) github.com/scriptogre/functi…
1
5
1,504
Struggling to remember which classes correspond to which methods? 🐍 This is a handy summary table: docs.python.org/3/library/co…
1
12
3,121
Did you know that a simple import can modify the Python interpreter? Import a custom module and suddenly, 8 becomes 9, and 9 becomes 8. kenschutte.com/python-swap-i…
5
14
5,043
Python 3.12 released today: * Type parameter syntax, the type statement and type aliases 🐍 * Syntactic formalization of f-strings πŸŽ‰ * A per-interpreter GIL πŸ”“ * Improved Did you mean … suggestions πŸ’‘ * Performance improvements in the asyncio package πŸš€ docs.python.org/3.12/whatsne…
50
1
98
18,997
BTW both of us (@karlafej & @simecek) are here at #EuroPython2023. If you run into us, feel free to say hello and what would you like to read as #pythontip. Greetings from Prague! πŸ‡¨πŸ‡Ώ
9
2,535
List comprehension exercise! Guess what will be the value in 'results' after running the code below πŸ‘‡πŸ‘‡ Try it on Colab gist.github.com/simecek/4c94… Or watch it on #EuroPython2023 Day1 ⚑ talk youtube.com/live/HHvm_TYhG14…
1
2
11
3,961
#EuroPython season! πŸπŸ’» You can watch most of the talks online, ep2023.europython.eu/live/fo… (note you can move the video back in time) (currently, @_inesmontani is closing Day1 with her fascinating keynote "Large Language Models: From Prototype to Production") ✨🎀 #EuroPython2023
3
13
3,809
survey = simple library for creating beautiful interactive prompts github.com/Exahilosys/survey
2
1
15
3,298
Something I was not aware of - (Ana)conda is not free for commercial use! You must either purchase a commercial license (~$150/year) or use alternative solutions like (mini)conda or mamba - see the comparison πŸ‘‡
3
9
4,329
PyAutoGUI helps you to to programmatically control the mouse & keyboard. github.com/asweigart/pyautog… Save a screenshot with three lines of code:
5
1
34
5,211
Use more_itertools library to access more advanced itertools functions, e.g. - split data into chunks - get sliding window over data - compress the sequence with run-length encoding
1
8
2
24
5,899
ruff = extremely fast Python linter, written in Rust github.com/charliermarsh/ruf…
Woah -- @huggingface has adopted Ruff for transformers and other projects. πŸ€—πŸ€—πŸ€—
1
5
1
19
7,009
IPython (Jupyter Notebook, Colab...) has a cell magic %%capture, which captures the stdout/stderr of a cell. notebook.community/lifeinopp… It can be also used to omit long output like installation messages in Colab setup cell, e.g. %%capture !pip install #...many packages
7
1
16
4,921
Euporie = run Jupyter notebooks entirely from the terminal github.com/joouha/euporie
8
54
11,456
Python 3.3 introduced `yield from` So instead of for v in my_generator: yield v you can write directly yield from my_generator Example:
1
5
26
5,443
Teaching Python? Avoid installation troubles and use @code and Python through GitHub Codespaces. This is a good intro: youtube.com/watch?v=7rMvb03h… And here you can find the template repository of a preconfigured environment: github.com/education/codespa…
7
34
9,307
In Python, the 'and' and 'or' operators can be used with any objects, not just boolean values. 1) 'and': returns the first operand if it is "falsy" (i.e. None, 0, ""), the second operand otherwise 2) 'or': returns the first operand if it is "truthy", second operand otherwise
1
7
28
5,664