Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/Tools/demo/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/Tools/demo/__pycache__/vector.cpython-37.pyc

B

� f��@s$dZGdd�d�Zdd�Ze�dS)zA
A demonstration of classes and their special methods in Python.
c@sXeZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZeZ
dS)�VecawA simple vector class.

    Instances of the Vec class can be constructed from numbers

    >>> a = Vec(1, 2, 3)
    >>> b = Vec(3, 2, 1)

    added
    >>> a + b
    Vec(4, 4, 4)

    subtracted
    >>> a - b
    Vec(-2, 0, 2)

    and multiplied by a scalar on the left
    >>> 3.0 * a
    Vec(3.0, 6.0, 9.0)

    or on the right
    >>> a * 3.0
    Vec(3.0, 6.0, 9.0)
    cGst|�|_dS)N)�list�v)�selfr�r�6/opt/alt/python37/lib64/python3.7/Tools/demo/vector.py�__init__szVec.__init__cCst|t�st�|�}||_|S)N)�
isinstancer�	TypeErrorr)�clsr�instrrr�fromlist"s

zVec.fromlistcCs d�dd�|jD��}d�|�S)Nz, css|]}t|�VqdS)N)�repr)�.0�xrrr�	<genexpr>+szVec.__repr__.<locals>.<genexpr>zVec({}))�joinr�format)r�argsrrr�__repr__*szVec.__repr__cCs
t|j�S)N)�lenr)rrrr�__len__.szVec.__len__cCs
|j|S)N)r)r�irrr�__getitem__1szVec.__getitem__cCs"dd�t|j|j�D�}t�|�S)NcSsg|]\}}||�qSrr)rr�yrrr�
<listcomp>6szVec.__add__.<locals>.<listcomp>)�ziprrr)r�otherrrrr�__add__4szVec.__add__cCs"dd�t|j|j�D�}t�|�S)NcSsg|]\}}||�qSrr)rrrrrrr;szVec.__sub__.<locals>.<listcomp>)rrrr)rrrrrr�__sub__9szVec.__sub__cs�fdd�|jD�}t�|�S)Ncsg|]}|��qSrr)rr)�scalarrrr@szVec.__mul__.<locals>.<listcomp>)rrr)rrrr)rr�__mul__>szVec.__mul__N)�__name__�
__module__�__qualname__�__doc__r�classmethodrrrrrrr �__rmul__rrrrrsrcCsddl}|��dS)N�)�doctestZtestmod)r(rrr�testFsr)N)r$rr)rrrr�<module>s?