Tuesday, August 16, 2016

Python’s attrs Library


You know what? I’m done. 20 lines of code so far and we don’t even have a class that does anything; the hard part of this problem was supposed to be the quaternion solver, not “make a data structure which can be printed and compared”. I’m all in on piles of undocumented garbage tuples, lists, and dictionaries it is; defining proper data structures well is way too hard in Python.


So here’s where my favorite mandatory Python library comes in.


import attr
class Point3D(object):
    x = attr.ib()
    y = attr.ib()
    z = attr.ib()

This is also a big pain in Objective-C. Swift structs are better, although you do need to make them Equatable.

Comments RSS · Twitter

Leave a Comment