[issue9703] default param values
vladimir
report at bugs.python.org
Sat Aug 28 00:31:08 CEST 2010
New submission from vladimir <golubovic.vladimir.gv at gmail.com>:
This program:
class t( object):
def __init__(self,ime,param1=[],param2=[]):
print "+++init+++"
print "ime = ",ime
print "param1 = ", param1
print "param2 = ", param2
print
self.ime = ime
self.sirina = param1
self.visina = param2
def load(self):
print "load self.ime = ",self.ime
self.sirina.append('a')
self.visina.append('b')
t1 = t("jedan",[1,2],[3,4])
t2 = t("dva",[5,6],[7,8])
t3 = t("tri")
t3.load()
t4 = t("cetiri")
produces this output:
+++init+++
ime = jedan
param1 = [1, 2]
param2 = [3, 4]
+++init+++
ime = dva
param1 = [5, 6]
param2 = [7, 8]
+++init+++
ime = tri
param1 = []
param2 = []
load self.ime = tri
+++init+++
ime = cetiri
param1 = ['a']
param2 = ['b']
Question:
How's possible that call t4 = t("cetiri")
gives param1 value ['a'] and
param2 value ['b']
Is it possible that is bug or my computer gone crazy or maybe i am
executed on:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
----------
messages: 115137
nosy: vladimir
priority: normal
severity: normal
status: open
title: default param values
type: behavior
versions: Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9703>
_______________________________________
More information about the Python-bugs-list
mailing list