Tags→ #Python
-
Changing python version in a running VSCode project
I was working on a python project with 3.11, and then found out I needed to upgrade to 3.12. Tried to deactivate my current venv, but VScode wouldn't let me - it threw a "Permission denied" error. The solution was pretty straightforward.
-
Pygraphviz Woes on M1 Mac: Docker to the Rescue
I was trying to install pygraphviz on my M1 laptop using pip, but I found it impossible. Luckily the Dev Container VSCode extension allows me to use it with docker.
-
mypy: found module but no type hints or library stubs
Linting a Python project, I was puzzled by the mysterious error: "found module but no type hints or library stubs" from mypy. The module was my own, with Pydantic definitions everywhere, so why the error? I was missing init.py files in some parent folders.
-
Faker providers for project specific data structure fakes, in Python
I am a big fan of Faker for testing. I find having a random mock data generator keeps tests clean. In fact, I tend to extend Faker with project specific providers. Here's how
-
Poetry-driven python project template with cookiecutter
My python toolchain for small projects does not change often. It makes sense to save it and then replicate it whenever I start a project. Or better, use cookiecutter and a config file to generate it
-
Removing duplicates from youtube playlists with a Python script
Thanks to a bug while copying a youtube playlist with a Python script, I ended up with a lot of duplicates videos in the playlist. Surprisingly, the YouTube interface doesn't let you remove them. So I put together another small Python script
-
Adding videos to a youtube playlists via a terminal python script
I wanted to duplicate another user's playlist to one of my free google accounts. But it's no longer possible from the web interface. None of the methods described in various SO answers are functional, they are obsolete. But it can be done with a Python script in your terminal.
-
Fixing autoformatting Django templates in Visual Studio Co
Prettier autoformatting screws up Django html templates in Visual Studio Code. For example, it puts tags on the same line when they shouldn't be. The fix is pretty simple and involves a couple of different formatting extension.
-
How I install python on OS X in 2022
There are many different ways of doing it; my favourite involves using pyenv