Skip to content

Commit 3271222

Browse files
committed
recovering @ example
1 parent cfa764d commit 3271222

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

docs/index.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,30 @@ Tests for operator `@` (Python >= 3.5), computing the dot product::
208208
.. literalinclude:: ../examples/vector_v5.py
209209

210210

211+
``vector_v5.py``
212+
----------------
213+
214+
Importing::
215+
216+
>>> from examples.vector_v5 import Vector
217+
218+
Tests for operator `@` (Python >= 3.5), computing the dot product::
219+
220+
>>> va = Vector([1, 2, 3])
221+
>>> vz = Vector([5, 6, 7])
222+
>>> va @ vz == 38.0 # 1*5 + 2*6 + 3*7
223+
True
224+
>>> [10, 20, 30] @ vz
225+
380.0
226+
>>> va @ 3
227+
Traceback (most recent call last):
228+
...
229+
TypeError: unsupported operand type(s) for @: 'Vector' and 'int'
230+
231+
.. literalinclude:: ../examples/vector_v5.py
232+
233+
234+
211235
``vector_v6.py``
212236
----------------
213237

examples/vector_v5.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ def __matmul__(self, other):
6464

6565
def __rmatmul__(self, other):
6666
return self @ other # só funciona em Python 3.5
67+

0 commit comments

Comments
 (0)