2021-10-12 12:55:26 +00:00
.. module :: attr
.. module :: attrs
2017-10-26 15:55:45 +00:00
======================================
`` attrs `` : Classes Without Boilerplate
======================================
2015-01-27 16:53:17 +00:00
2019-09-09 13:02:16 +00:00
Release v\ |release| (`What's new? <changelog>` ).
2015-01-27 16:53:17 +00:00
.. include :: ../README.rst
2015-01-27 21:41:24 +00:00
:start-after: teaser-begin
2020-03-08 06:30:03 +00:00
:end-before: teaser-end
2016-08-15 15:24:09 +00:00
2017-10-26 15:55:45 +00:00
Getting Started
===============
2015-01-27 16:53:17 +00:00
2017-10-26 15:55:45 +00:00
`` attrs `` is a Python-only package `hosted on PyPI <https://pypi.org/project/attrs/> `_ .
The recommended installation method is `pip <https://pip.pypa.io/en/stable/> `_ -installing into a `virtualenv <https://hynek.me/articles/virtualenv-lives/> `_ :
2015-01-27 16:53:17 +00:00
2017-10-26 15:55:45 +00:00
.. code-block :: console
2015-01-27 16:53:17 +00:00
2020-03-08 06:30:03 +00:00
$ python -m pip install attrs
2015-01-27 16:53:17 +00:00
2017-10-26 15:55:45 +00:00
The next three steps should bring you up and running in no time:
2019-09-09 13:02:16 +00:00
- `overview` will show you a simple example of `` attrs `` in action and introduce you to its philosophy.
2021-11-24 08:39:41 +00:00
Afterwards, you can start writing your own classes and understand what drives `` attrs `` 's design.
2019-09-09 13:02:16 +00:00
- `examples` will give you a comprehensive tour of `` attrs `` 's features.
2017-10-26 15:55:45 +00:00
After reading, you will know about our advanced features and how to use them.
2021-11-24 08:39:41 +00:00
- If you're confused by all the `` attr.s `` , `` attr.ib `` , `` attrs `` , `` attrib `` , `` define `` , `` frozen `` , and `` field `` , head over to `names` for a very short explanation, and optionally a quick history lesson.
2019-09-09 13:02:16 +00:00
- Finally `why` gives you a rundown of potential alternatives and why we think `` attrs `` is superior.
2018-07-28 11:05:12 +00:00
Yes, we've heard about `` namedtuple ` ` \ s and Data Classes!
2019-09-09 13:02:16 +00:00
- If at any point you get confused by some terminology, please check out our `glossary` .
2017-10-26 15:55:45 +00:00
2021-10-28 05:11:16 +00:00
If you need any help while getting started, feel free to use the `` python-attrs `` tag on `Stack Overflow <https://stackoverflow.com/questions/tagged/python-attrs> `_ and someone will surely help you out!
2017-10-26 15:55:45 +00:00
Day-to-Day Usage
================
2019-09-09 13:02:16 +00:00
- `types` help you to write *correct* and *self-documenting* code.
`` attrs `` has first class support for them and even allows you to drop the calls to `attr.ib` on modern Python versions!
2018-04-24 22:07:03 +00:00
- Instance initialization is one of `` attrs `` key feature areas.
Our goal is to relieve you from writing as much code as possible.
2019-09-09 13:02:16 +00:00
`init` gives you an overview what `` attrs `` has to offer and explains some related philosophies we believe in.
2021-02-26 06:53:57 +00:00
- Comparing and ordering objects is a common task.
`comparison` shows you how `` attrs `` helps you with that and how you can customize it.
2018-04-16 05:49:34 +00:00
- If you want to put objects into sets or use them as keys in dictionaries, they have to be hashable.
2019-09-09 13:02:16 +00:00
The simplest way to do that is to use frozen classes, but the topic is more complex than it seems and `hashing` will give you a primer on what to look out for.
- Once you're comfortable with the concepts, our `api` contains all information you need to use `` attrs `` to its fullest.
2017-10-26 15:55:45 +00:00
- `` attrs `` is built for extension from the ground up.
2019-09-09 13:02:16 +00:00
`extending` will show you the affordances it offers and how to make it a building block of your own projects.
2015-01-27 16:53:17 +00:00
2015-01-28 17:23:15 +00:00
2017-10-26 15:55:45 +00:00
.. include :: ../README.rst
2020-03-08 06:30:03 +00:00
:start-after: -getting-help-
:end-before: -project-information-
2015-01-27 16:53:17 +00:00
2017-10-26 15:55:45 +00:00
----
Full Table of Contents
======================
.. toctree ::
:maxdepth: 2
overview
why
examples
2018-07-28 11:05:12 +00:00
types
2018-04-24 22:07:03 +00:00
init
2021-02-26 06:53:57 +00:00
comparison
2018-04-16 05:49:34 +00:00
hashing
2017-10-26 15:55:45 +00:00
api
extending
how-does-it-work
2021-11-24 08:39:41 +00:00
names
2018-05-02 05:24:04 +00:00
glossary
2017-10-26 15:55:45 +00:00
2015-01-27 16:53:17 +00:00
2020-03-08 06:30:03 +00:00
.. include :: ../README.rst
:start-after: -project-information-
.. toctree ::
:maxdepth: 1
license
python-2
changelog
2015-01-27 16:53:17 +00:00
Indices and tables
==================
2019-09-09 13:02:16 +00:00
* `genindex`
* `search`