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/2003-May/035593.html below:

[Python-Dev] Inplace multiply

[Python-Dev] Inplace multiplyJeff Epler jepler@unpythonic.net
Tue, 13 May 2003 13:31:45 -0500
There must be something more to your problem than what you described.

The following executes just fine for me (ditto if NewKoke is a subclass
of object instead of list, and no matter whether I define __getitem__ or
not [a guess based on your remark about 'multiply a sequence']):

$ python dubois.py
sausages vegetable-style breakfast patty
sausages vegetable-style breakfast patty

class Klassic:
    def __imul__(self, other):
        return "sausages"
    def __getitem__(self, i): return None

class NewKoke(list):
    def __imul__(self, other):
        return "vegetable-style breakfast patty"
    def __getitem__(self, i): return None

k = Klassic()
o = NewKoke()

k *= 1
o *= 1

print k, o

k = Klassic()
o = NewKoke()

k *= "spam"
o *= "spam"

print k, o



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