V Qc@s'dddYZdZedS(tVeccBsbeZdZdZedZdZdZdZdZ dZ dZ e Z RS( sx A 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(tlisttv(tselfR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__init__scCs.t|tstn|}||_|S(N(t isinstanceRt TypeErrorR(tclsRtinst((s(/usr/lib64/python2.7/Demo/classes/Vec.pytfromlists    cCs)djd|jD}dj|S(Ns, css|]}t|VqdS(N(trepr(t.0tx((s(/usr/lib64/python2.7/Demo/classes/Vec.pys %ssVec({0})(tjoinRtformat(Rtargs((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__repr__$scCs t|jS(N(tlenR(R((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__len__(scCs |j|S(N(R(Rti((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt __getitem__+scCs?gt|j|jD]\}}||^q}tj|S(N(tzipRRR (RtotherR tyR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__add__.s2cCs?gt|j|jD]\}}||^q}tj|S(N(RRRR (RRR RR((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__sub__3s2cCs-g|jD]}||^q }tj|S(N(RRR (RtscalarR R((s(/usr/lib64/python2.7/Demo/classes/Vec.pyt__mul__8s ( t__name__t __module__t__doc__Rt classmethodR RRRRRRt__rmul__(((s(/usr/lib64/python2.7/Demo/classes/Vec.pyRs       cCsddl}|jdS(Ni(tdoctestttestmod(R!((s(/usr/lib64/python2.7/Demo/classes/Vec.pyttest@s N((RR#(((s(/usr/lib64/python2.7/Demo/classes/Vec.pyts?