Bite Code! Profile picture
Quality and to-the-point bites about the Python world. And other tech stuff. Get more on https://t.co/9FXghun0Cp
Oct 22, 2022 4 tweets 1 min read
Every time I read something on asyncio, it says await allows asyncronous non blocking IO code to be run concurrently. While it's true, it is not helpful to think that way to write the code.

It's better to think about await as locally blocking and... ... isolate the worflow that contains a few await into it's own separate coroutine. The coroutine is the real unit of concurrency. It is suspended on await, and so from the point of view of inside the coro, await is blocking, that's the whole point of the keyword.
Feb 27, 2020 7 tweets 1 min read
If you wish to improve the quality of your python code, tooling is a low hanging fruit.

Start with black, pylint, mypy and pytest. They will push you to write better code.

However, installing these tools, while not difficult, comes with a few gotchas I'm here to help you avoid: 1 - Install stuff correctly

Either you are in a virtualenv and you can do "pip install package".

OR you are NOT in a virtualenv and you should do:

{your_python_version_here} -m pip install package --user

No sudo. No admin console.
Oct 26, 2019 5 tweets 2 min read
If you don't know what setup.cfg is, it's the simplest, easiest most bulletproof way to make Python 3 packages.

Here is how you do it. 1 - Create a setup.py file containing a single line:

import setuptools; setuptools.setup()

It should be in the same dir as your importable lib. Not inside, not in a parent dir. Next to it.

Let's say your importable lib is called "cool_package". Now...