Tuesday, August 16, 2016 [Tweets] [Favorites]

Python’s attrs Library

@glyph:

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
@attr.s
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

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment