[issue16372] Initialization strange behavior

Wojciech Danilo report at bugs.python.org
Wed Oct 31 15:18:19 CET 2012


New submission from Wojciech Danilo:

Hi!
I'm using Python for several years and now I'm writing in Python 3 for the first time. I think I found a strange bug in it. Lets concider the code in the attachement.
In the 33 line there is construction of new instance of class Result:
print('!!!',Result().value)
what is strange, the class is defined as:
class Result:
    def __init__(self, value=[], start=0, end=0):
        self.value = value
        ...

and what I get as a result is:
"!!! ['a', 'b']"

Where the array was somehow magically stored from previous initialization (take a look at the code for full listing).

----------
components: Interpreter Core
files: test.py
messages: 174280
nosy: wdanilo
priority: normal
severity: normal
status: open
title: Initialization strange behavior
versions: Python 3.3
Added file: http://bugs.python.org/file27809/test.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16372>
_______________________________________


More information about the Python-bugs-list mailing list