Poetry equivalent of `python develop`

To use the package you’re working on directly in the project itself. Go to the directory where your package is being developed, where the pyproject.toml file resides:

poetry install
poetry shell

I fought days with it and it ended up being that simple. *Facepalm*.

If necessary, remove the previously created venv first.

To use it in a different project though, you’d probably need something like this.


SQLAlchemy: Difference between Flush and Commit

In simple terms:

  • Similarity: after both flush and commit, later queries will be able to retrieve these changes.
  • Difference: flush() changes are in a pending state (no db statements are issued yet), and can be undone by rollback(); commits are persisted to db and non-reversible.

Why use flush:

  • To have atomicity–making sure that a group of transactions either all succeed or all fail.


Python Function Fun Facts

A string identifier is attached to every function at creation time

  • Which is nice for debug:
>>> dance.__name__

Functions capture local state

  • Just like JavaScript, (lexical) closure:
  • A closure remembers the values from its enclosing scope when it was created

To check whether something is callable

  • Objects can be made callable, by being assigned function as value
  • So, to check whether an object is callable:
>>> callable(foo)

Benefit of functions being first class

  • We are able to abstract and pass around behaviours