diff --git a/README.md b/README.md index 0fc6fd6..b3b1059 100644 --- a/README.md +++ b/README.md @@ -967,7 +967,7 @@ class : * **If only repr() is defined, it will also be used for str().** * **Methods decorated with `'@staticmethod'` do not receive 'self' nor 'cls' as their first arg.** -#### Str() use cases: +#### Expressions that call the str() method: ```python print() f'{}' @@ -976,7 +976,7 @@ csv.writer().writerow([]) raise Exception() ``` -#### Repr() use cases: +#### Expressions that call the repr() method: ```python print/str/repr([]) f'{!r}' @@ -1261,7 +1261,7 @@ class MyCollection: * **Only required methods are len() and getitem().** * **Getitem() should return an item at the passed index or raise IndexError.** * **Iter() and contains() automatically work on any object that has getitem() defined.** -* **Reversed() automatically works on any object that has len() and getitem() defined.** +* **Reversed() automatically works on any object that has getitem() and len() defined.** ```python class MySequence: def __init__(self, a): diff --git a/index.html b/index.html index 5703327..33b392a 100644 --- a/index.html +++ b/index.html @@ -827,14 +827,14 @@ player = Player(point, direction) #
  • If only repr() is defined, it will also be used for str().
  • Methods decorated with '@staticmethod' do not receive 'self' nor 'cls' as their first arg.
  • -

    Str() use cases:

    print(<el>)
    +

    Expressions that call the str() method:

    print(<el>)
     f'{<el>}'
     logging.warning(<el>)
     csv.writer(<file>).writerow([<el>])
     raise Exception(<el>)
     
    -

    Repr() use cases:

    print/str/repr([<el>])
    +

    Expressions that call the repr() method:

    print/str/repr([<el>])
     f'{<el>!r}'
     Z = dataclasses.make_dataclass('Z', ['a']); print/str/repr(Z(<el>))
     >>> <el>
    @@ -1080,7 +1080,7 @@ Hello World!
     
  • Only required methods are len() and getitem().
  • Getitem() should return an item at the passed index or raise IndexError.
  • Iter() and contains() automatically work on any object that has getitem() defined.
  • -
  • Reversed() automatically works on any object that has len() and getitem() defined.
  • +
  • Reversed() automatically works on any object that has getitem() and len() defined.
  • class MySequence:
         def __init__(self, a):
             self.a = a