Rose Ridder added the comment:
Sorry, incorrect code pasted in. The full comment and code is below:
When creating several objects in one program, if there are lists passed into
functions as optional arguments, those lists are persistent across all objects.
# -*- coding: utf-8 -*-
class Obj
Rose Ridder added the comment:
Including script explicitly:
# -*- coding: utf-8 -*-
class Obj:
def __init__(self, num):
self.num = num
self.var = self.funct()
def funct(self, array = []):
print (array)
array = [1,2,3]
return array
New submission from Rose Ridder :
When creating several objects in one program, if there are lists passed into
functions as optional arguments, those lists are persistent across all objects.
--
components: ctypes
files: PythonObjectListIssue.py
messages: 381153
nosy: rosadenderon