Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
For the usage of attr with DB API 2.0 libraries (like Sqlite3), it would be great to have a
This method would return the object values in a tuple, ordered by the order of declaration of it's attributes.
For example we could do things like this :
import sqlite3 import attr @attr.s() class Foo: a = attr.ib() b = attr.ib() foo = Foo(2, 3) con = sqlite3.connect(":memory:") with con: con.execute("INSERT INTO foo VALUES (?, ?)", attr.astuple(foo))
This would be useful for DB API libraries but also for other needs probably.
What is your opinion about it ?
We should probably try to mirror
For nested attr classes, this would be:
For built-in collections... Just do what
Another side of the mirroring: an non-nested attr class can be dumped and loaded like this:
so tuples work in a similar way: