attrs
: Classes Without Boilerplate¶
Release v17.4.0 (What’s new?).
attrs
is the Python package that will bring back the joy of writing classes by relieving you from the drudgery of implementing object protocols (aka dunder methods).
Its main goal is to help you to write concise and correct software without slowing down your code.
Getting Started¶
attrs
is a Python-only package hosted on PyPI.
The recommended installation method is pip-installing into a virtualenv:
$ pip install attrs
The next three steps should bring you up and running in no time:
- Overview will show you a simple example of
attrs
in action and introduce you to its philosophy. Afterwards, you can start writing your own classes, understand what drivesattrs
’s design, and know what@attr.s
andattr.ib()
stand for. - attrs by Example will give you a comprehensive tour of
attrs
’s features. After reading, you will know about our advanced features and how to use them. - Finally Why not… gives you a rundown of potential alternatives and why we think
attrs
is superior. Yes, we’ve heard aboutnamedtuple
s!
If you need any help while getting started, feel free to use the python-attrs
tag on StackOverflow and someone will surely help you out!
Day-to-Day Usage¶
- Once you’re comfortable with the concepts, our API Reference contains all information you need to use
attrs
to its fullest. attrs
is built for extension from the ground up. Extending will show you the affordances it offers and how to make it a building block of your own projects.
Testimonials¶
Amber Hawkie Brown, Twisted Release Manager and Computer Owl:
Writing a fully-functional class using attrs takes me less time than writing this testimonial.
Glyph Lefkowitz, creator of Twisted, Automat, and other open source software, in The One Python Library Everyone Needs:
I’m looking forward to is being able to program in Python-with-attrs everywhere. It exerts a subtle, but positive, design influence in all the codebases I’ve see it used in.
Kenneth Reitz, author of requests, Python Overlord at Heroku, on paper no less:
attrs—classes for humans. I like it.
Łukasz Langa, prolific CPython core developer and Production Engineer at Facebook:
I’m increasingly digging your attr.ocity. Good job!
Getting Help¶
Please use the python-attrs
tag on StackOverflow to get help.
Answering questions of your fellow developers is also great way to help the project!
Project Information¶
attrs
is released under the MIT license,
its documentation lives at Read the Docs,
the code on GitHub,
and the latest release on PyPI.
It’s rigorously tested on Python 2.7, 3.4+, and PyPy.
If you’d like to contribute you’re most welcome and we’ve written a little guide to get you started!