Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
class Vec:
|
|
|
|
""" A simple vector class
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
Instances of the Vec class can be constructed from numbers
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
>>> a = Vec(1, 2, 3)
|
|
|
|
>>> b = Vec(3, 2, 1)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
added
|
|
|
|
>>> a + b
|
|
|
|
Vec(4, 4, 4)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
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)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
or on the right
|
|
|
|
>>> a * 3.0
|
|
|
|
Vec(3.0, 6.0, 9.0)
|
|
|
|
"""
|
2003-04-24 14:13:18 -03:00
|
|
|
def __init__(self, *v):
|
2003-09-10 18:12:59 -03:00
|
|
|
self.v = list(v)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
@classmethod
|
|
|
|
def fromlist(cls, v):
|
2003-09-10 18:12:59 -03:00
|
|
|
if not isinstance(v, list):
|
2003-04-24 14:13:18 -03:00
|
|
|
raise TypeError
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
inst = cls()
|
|
|
|
inst.v = v
|
|
|
|
return inst
|
1992-08-13 09:14:11 -03:00
|
|
|
|
2003-04-24 14:13:18 -03:00
|
|
|
def __repr__(self):
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
args = ', '.join(repr(x) for x in self.v)
|
|
|
|
return 'Vec({})'.format(args)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
2003-04-24 14:13:18 -03:00
|
|
|
def __len__(self):
|
|
|
|
return len(self.v)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
2003-04-24 14:13:18 -03:00
|
|
|
def __getitem__(self, i):
|
|
|
|
return self.v[i]
|
1992-08-13 09:14:11 -03:00
|
|
|
|
2003-09-10 18:12:59 -03:00
|
|
|
def __add__(self, other):
|
2003-04-24 14:13:18 -03:00
|
|
|
# Element-wise addition
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
v = [x + y for x, y in zip(self.v, other.v)]
|
|
|
|
return Vec.fromlist(v)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
2003-09-10 18:12:59 -03:00
|
|
|
def __sub__(self, other):
|
2003-04-24 14:13:18 -03:00
|
|
|
# Element-wise subtraction
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
v = [x - y for x, y in zip(self.v, other.v)]
|
|
|
|
return Vec.fromlist(v)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
2003-04-24 14:13:18 -03:00
|
|
|
def __mul__(self, scalar):
|
|
|
|
# Multiply by scalar
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
v = [x * scalar for x in self.v]
|
|
|
|
return Vec.fromlist(v)
|
1992-08-13 09:14:11 -03:00
|
|
|
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
__rmul__ = __mul__
|
1992-08-13 09:14:11 -03:00
|
|
|
|
|
|
|
|
|
|
|
def test():
|
Merged revisions 82262,82269,82434,82480-82481,82484-82485,82487-82488,82594,82599,82615 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
................
r82262 | georg.brandl | 2010-06-27 12:17:12 +0200 (So, 27 Jun 2010) | 1 line
#9078: fix some Unicode C API descriptions, in comments and docs.
................
r82269 | georg.brandl | 2010-06-27 12:59:19 +0200 (So, 27 Jun 2010) | 1 line
Wording fix.
................
r82434 | georg.brandl | 2010-07-02 09:41:51 +0200 (Fr, 02 Jul 2010) | 9 lines
Merged revisions 82433 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82433 | georg.brandl | 2010-07-02 09:33:50 +0200 (Fr, 02 Jul 2010) | 1 line
Grammar and markup fixes.
........
................
r82480 | georg.brandl | 2010-07-03 12:21:50 +0200 (Sa, 03 Jul 2010) | 1 line
Wrap and use the correct directive.
................
r82481 | georg.brandl | 2010-07-03 12:22:10 +0200 (Sa, 03 Jul 2010) | 1 line
Use the right role.
................
r82484 | georg.brandl | 2010-07-03 12:26:17 +0200 (Sa, 03 Jul 2010) | 9 lines
Recorded merge of revisions 82474 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82474 | georg.brandl | 2010-07-03 10:40:13 +0200 (Sa, 03 Jul 2010) | 1 line
Fix role name.
........
................
r82485 | georg.brandl | 2010-07-03 12:26:54 +0200 (Sa, 03 Jul 2010) | 9 lines
Merged revisions 82483 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82483 | georg.brandl | 2010-07-03 12:25:54 +0200 (Sa, 03 Jul 2010) | 1 line
Add link to bytecode docs.
........
................
r82487 | georg.brandl | 2010-07-03 12:33:26 +0200 (Sa, 03 Jul 2010) | 1 line
Fix markup.
................
r82488 | georg.brandl | 2010-07-03 12:41:33 +0200 (Sa, 03 Jul 2010) | 1 line
Remove the need for a "()" empty argument list after opcodes.
................
r82594 | georg.brandl | 2010-07-05 22:13:41 +0200 (Mo, 05 Jul 2010) | 1 line
Update Vec class constructor, remove indirection via function, use operator module.
................
r82599 | alexander.belopolsky | 2010-07-05 23:44:05 +0200 (Mo, 05 Jul 2010) | 1 line
"Modernized" the demo a little.
................
r82615 | georg.brandl | 2010-07-07 00:58:50 +0200 (Mi, 07 Jul 2010) | 1 line
Fix typo.
................
2010-10-06 05:08:40 -03:00
|
|
|
import doctest
|
|
|
|
doctest.testmod()
|
1992-08-13 09:14:11 -03:00
|
|
|
|
|
|
|
test()
|