A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-March/021797.html below:

[Python-Dev] In-place multiply and new style classes

[Python-Dev] In-place multiply and new style classesTodd Miller jmiller@stsci.edu
Wed, 27 Mar 2002 13:34:17 -0500
Hi,

I'm Todd Miller and I work at the Space Telescope Science Institute on 
Numarray.  
Numarray is STSCI's stab at improving Numeric.  This is my first post here.

Today one of the guys in my branch  noticed that Numarray's in-place 
multiply was
raising this bizarre exception:

--> a = ones ((5,), Float32)
--> a
array([1., 1., 1., 1., 1.], type=Float32)
--> a *= 62.
Traceback (innermost last):
  File "<console>", line 1, in ?
TypeError: can't multiply sequence to non-int


I looked into this for a couple hours and discovered the following:

class test1(object):
    """A new-style class"""
    def __init__(self):
        pass

    def __imul__(self, other):
        print "no luck here!"

>>> t1 = test1()
>>> t1 *= 62.
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: can't multiply sequence to non-int



Todd


-- 
Todd Miller 			jmiller@stsci.edu
STSCI / SSG			(410) 338 4576





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4