Bugs item #1777160, was opened at 2007-08-19 10:25 Message generated for change (Comment added) made by gbrandl You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1777160&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Documentation Group: Feature Request >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Greg Kochanski (gpk) Assigned to: Nobody/Anonymous (nobody) Summary: Please warn about a subtle trap Initial Comment: In python, -1**2 is -1. This will horribly surprise most mathematicians or C programmers where unary - binds very tightly. Such people will expect -1**2 == 1. This problem shows up in scientific contexts, especially Numpy, where an easy way to generate an alternating string of positive and negative numbers is -1**numpy.arange(10). In this example, one expects to produce [1, -1, 1, -1, ...]. So, please put a note in the documentation warning of this problem. It can lead to subtly wrong computations. The appropriate place to put the note is in the Python Reference Manual, section 5.4, The Power operator. Please insert a final line saying: "Note: since the minus sign is not part of a numeric literal, powers of negative numeric constants need to be written with parentheses. Be aware that -1**2 == -(1**2), not (-1)**2." ---------------------------------------------------------------------- >Comment By: Georg Brandl (gbrandl) Date: 2007-08-21 06:07 Message: Logged In: YES user_id=849994 Originator: NO Thanks, fixed in rev. 57255. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1777160&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com