K = MyObj() K.Lines.append('First line to Obj "K"') K.Lines.append('Second line to Obj "K"') L = MyObj() L.Lines.append('First line to Obj "L"') print 'Lines from Obj "K"',K.Lines print 'Lines from Obj "L"',L.Lines Result is: [Dbg]>>> Lines from Obj "K" ['First line to Obj "K"', 'Second line to Obj "K"', 'First line to Obj "L"'] Lines from Obj "L" ['First line to Obj "K"', 'Second line to Obj "K"', 'First line to Obj "L"'] >>> Why data appended into nested list filed “Lines†into different object “K†and “L†appears in both objects ?
Sadly you didn't attach the definition of the class "MyObj". I assume it is like this: class MyObj: Lines = [] In this case, the Lines list object is shared by all instances of MyObj. Please post to the python-list mailing list for further questions about this behavior. If your bug is different, please feel free to reopen this.
Sorry :( I forgot to paste definision of Class MyObj yes it is: class MyObj: Lines = [] -------------------------------------- is this a bug ? Or always in Python data in nested object are shared between all objects from same class