strange behaviour when inheriting from tuple

metal metal29a at gmail.com
Sun Oct 11 09:04:20 CEST 2009


Environment:

PythonWin 2.5.4 (r254:67916, Apr 27 2009, 15:41:14) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin'
for further copyright information.

Evil Code:

class Foo:
	def __init__(self, *args):
		print args

Foo(1, 2, 3) # (1, 2, 3), good

class Bar(tuple):
	def __init__(self, *args):
		print args

Bar(1, 2, 3) # TypeError: tuple() takes at most 1 argument (3 given)

what the heck? I even didn't call tuple.__init__ yet




More information about the Python-list mailing list