The Leading Python Class Definition Systems

I have been surveying Python class definition systems for awhile and yesterday I watched a webcast of Param and was very impressed. Param is the bottom floor of a very impressive data science / web application development stack that has 100% support from Anaconda. Param was developed for over 10 years in academia.

What other powerful object systems are there besides Param? Pydantic

Pydantic is quite popular but lacks the reactive capabilities that Param, Atom, Traits and Traitlets have. It also is more about type conversion than validation (according to yesterday’s webinar). There is quite a bit of tooling around Pydantic in the form of Pydantic settings (for configuring apps), Pydantic-CLI (and Typer) for command-line interfaces, and Pydantic-SQLAlchemy to make using SQLAlchemy even easier. And FastAPI appears to use it under the hood. And FastAPI is the 3rd most popular web framework in Python behind Django and Flask.

So while numerous object systems are more featureful than Pydantic, another one is much faster


Final Mention for now – CubicWeb

CubicWeb is another object system that comes with a massive infrastructure around it. Even though you define classes similar to these other libraries, are you actually creating a UML relational structure which pumps out CRUD apps and has been doing so for over a decade!

SOLVED: AttributeError: ‘_thread._local’ object has no attribute ‘_pydal_connection_140103876850296_30686’

I have been using web2py’s pyDAL with no problem for a long time. However, recently I started getting the error mentioned in the title and this stacktrace.

I googled about and for some reason a certain pyDAL thread came up. And in one of the comments I saw some code which forced a reconnect.

So I took my instance of pyDAL and forced a reconnect before inserting:

def record_buy(config_file, order_id, mkt, rate, amount):
 """Store the details of a coin purchase.

Create a new record in the `buy` table.

            order_id=order_id, market=mkt, purchase_price=rate, amount=amount)

And wallah! No more error!

Generating class diagrams from Python code

I had written some of my most complicated OO Python to-date, using a mixture of SQLAlchemy and Nagare. I found 2 excellent tools for generating class diagrams:

pyreverse within the PyLint distribution is excellent

– and PyNsource is amazing as well

I ended up mainly using the first one, because all I had to do with `pip install pylint` and then pyreverse -o png -p app .