From 4759f4659d0a851e58c6bd1d5b50efea4e82b586 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Tue, 16 Aug 2016 12:25:22 +0200 Subject: [PATCH] Address feedback to examples.rst Ref #59 --- docs/examples.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/examples.rst b/docs/examples.rst index 4c7af706..1c94daa3 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -22,7 +22,7 @@ The simplest possible usage would be: >>> Empty() is Empty() False -So in other words -- ``attrs``: useful even without actual attributes! +So in other words: ``attrs`` is useful even without actual attributes! But you'll usually want some data on your classes, so let's add some: @@ -222,7 +222,7 @@ And sometimes you even want mutable objects as default values (ever used acciden ... socket = attr.ib() ... @classmethod ... def connect(cls, db_string): - ... # connect somehow to db_string + ... # ... connect somehow to db_string ... ... return cls(socket=42) >>> @attr.s ... class ConnectionPool(object): @@ -261,9 +261,9 @@ Although your initializers should be as dumb as possible, it can come in handy t That's when :func:`attr.ib`\ ’s ``validator`` argument comes into play. A validator is simply a callable that takes three arguments: -#. The *instance* that's being validated. -#. The *attribute* that it's validating -#. and finally the *value* that is passed for it. +#. the *instance* that's being validated, +#. the *attribute* that it's validating, and finally +#. the *value* that is passed for it. If the value does not pass the validator's standards, it just raises an appropriate exception. Since the validator runs *after* the instance is initialized, you can refer to other attributes while validating : @@ -384,7 +384,7 @@ Slots ----- By default, instances of classes have a dictionary for attribute storage. -This wastes space for objects having very few instance variables. +This wastes space for objects having very few data attributes. The space consumption can become significant when creating large numbers of instances. Normal Python classes can avoid using a separate dictionary for each instance of a class by `defining `_ ``__slots__``.