{"id":15560,"date":"2016-08-16T16:34:18","date_gmt":"2016-08-16T20:34:18","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=15560"},"modified":"2016-08-16T16:34:18","modified_gmt":"2016-08-16T20:34:18","slug":"pythons-attrs-library","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2016\/08\/16\/pythons-attrs-library\/","title":{"rendered":"Python&rsquo;s attrs Library"},"content":{"rendered":"<p><a href=\"https:\/\/glyph.twistedmatrix.com\/2016\/08\/attrs.html\">@glyph<\/a>:<\/p>\n<blockquote cite=\"https:\/\/glyph.twistedmatrix.com\/2016\/08\/attrs.html\"><p>You know what? I&rsquo;m done.  20 lines of code so far and we don&rsquo;t even have a\nclass that <em>does<\/em> anything; the hard part of this problem was supposed to be\nthe quaternion solver, not &ldquo;make a data structure which can be printed and\ncompared&rdquo;.  I&rsquo;m <em>all in<\/em> on piles of undocumented garbage tuples, lists, and\ndictionaries it is; defining proper data structures well is way too hard in\nPython.<\/p>\n<p>[&#8230;]<\/p>\n<p>So here&rsquo;s where my favorite mandatory Python library comes in.<\/p>\n<p>[&#8230;]<\/p>\n<pre>import attr\n@attr.s\nclass Point3D(object):\n    x = attr.ib()\n    y = attr.ib()\n    z = attr.ib()<\/pre><\/blockquote>\n<p>This is also a big pain in Objective-C. Swift structs are better, although you do need to make them <code>Equatable<\/code>.<\/p>","protected":false},"excerpt":{"rendered":"<p>@glyph: You know what? I&rsquo;m done. 20 lines of code so far and we don&rsquo;t even have a class that does anything; the hard part of this problem was supposed to be the quaternion solver, not &ldquo;make a data structure which can be printed and compared&rdquo;. I&rsquo;m all in on piles of undocumented garbage tuples, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[71,232],"class_list":["post-15560","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-programming","tag-python"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=15560"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15560\/revisions"}],"predecessor-version":[{"id":15561,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/15560\/revisions\/15561"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=15560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=15560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=15560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}