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) π
I just discovered Behind the Commit podcast! π§ (hosted by Mia BajiΔ ποΈ)
First two episodes feature Python release managers Hugo van Kemenade (3.14&3.15), Pablo Galindo Salgado (3.10&3.11), Εukasz Langa (3.8&3.9)
and
FastAPI creator SebastiΓ‘n RamΓrez
open.spotify.com/show/2Z9Ewkβ¦
I once told at a conference dinner: "Iβve got a PhD, but 90% of my work is just applying @fastdotai stuff"
A senior researcher nodded: "Same" π
So when the new course dropped, I needed ~60s to subscribe (2-wk refund)
solve.it.com/?via_id=gifvtbwβ¦
15% off (and yes, I get 15% too)
Need pandas Jupyter for quick analysis but don't want them in your production dependencies?
uv run --with pandas --with jupyter jupyter lab
One command. Zero environment pollution. β¨
#uv#jupyter#DevTips
Two Python gems Iβve been playing with:
π Tenacity β painless retry logic for anything. No more rolling your own loops sleeps
tenacity.readthedocs.io/en/lβ¦
β‘ DumPy β a bold rethink of NumPy: βdonβt make me think, just run (fast, on GPUs)β
dynomight.net/dumpy/
Both worth a π
Today I learned... `uv init` now not only creates a new Python environment but also creates
βββ .gitignore
βββ README.md
βββ main.py
βββ pyproject.toml
βββ .python-version
realpython.com/python-uv/#crβ¦
marimo = Jupyter for serious Python work π₯
- Pure .py files (git-friendly!)
- No more restart & run all
- Deploy as scripts OR interactive web apps
- Built-in SQL support
- Reactive cells that auto-update dependencies
marimo.io/
When I started with Python, I was confused by the murky difference between variables and references. π€
This π explains it brilliantly:
Why Python has No Variables?
medium.com/@king_star/why-pyβ¦
This is neat! Instead of writing scraping methods yourself, provide a few examples and let `autoscraper` to do it for you.
oxylabs.io/blog/automated-weβ¦
If you want to automatically scrape a website with Python, use `autoscraper` π‘
Its almost magical πͺ - Instead of writing the scraping logic manually, you provide a few sample values you'd like to scrape, and `autoscraper` will deduce the scraping rules for you.
It learns the scraping rules and returns the similar elements. Then you can use this learned object with new urls to get similar content or the exact same element of those new pages.
`autoscraper` doesn't require detailed XPath or CSS selectors like traditional scraping libraries. Instead, it automates the pattern recognition process by learning from the example you provide.
Let's design an example where we'll scrape the latest headlines from a popular news website. (Disclaimer: Make sure you have the legal right to scrape the desired website; scraping some sites might be against their terms of service).
Suppose we want to scrape the latest headlines from "BBC News" (for demonstration purposes only).
Remember to replace the "BBC News headline example" with an actual headline from the BBC News page so that the model can learn from it. After running the script, you should see a list of scraped headlines.
Automate your virtualenv activation!
Using autoenv (github.com/hyperupcall/autoeβ¦), you can:
1. Automatically activate virtualenv when entering a directory
2. Run ANY command when cd-ing into a folder
Example:
# Set up autoenv
echo "source venv/bin/activate" > .env
# Or run custom commands
echo "echo 'Project: $(pwd)'" >> .env
cd ./project # Triggers .env automatically! πͺ
AI is changing how we code, but should it change how we teach Python? I've embraced LLMs for coding, especially with pandas, but I'm unsure if beginners should start this way.
Anyway, curious about the AI way? Try Andrew Ng's 'AI Python for Beginners': deeplearning.ai/short-courseβ¦
Here's an interesting Python brainteaser that came from a member asking a question on The Python Coding Place forumβ¦
Can you figure out why the outputs are the way they are for these two similar but not identical bits of code?
The answer gives a great insight on iteratorsβ¦
ALT data = [1, 2, 3, 4, 5, 6, 7]
for number in range(1, 5):
data = (item for item in data if item != number)
print(list(data))
# [1, 2, 3, 5, 6, 7] Note 4 is missing
data = [1, 2, 3, 4, 5, 6, 7]
for number in range(1, 5):
data = [item for item in data if item != number]
print(list(data))
# [5, 6, 7]