[issue35339] Populating instances of class automatically

2018-11-28 Thread Steven D'Aprano


Change by Steven D'Aprano :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35339] Populating instances of class automatically

2018-11-28 Thread Daugeras


Daugeras  added the comment:

Hi Geoffrey,

Indeed you where right, this is not a bug.
The link you provided did solve my problem.
I declared classes with attributes as strings, lists, etc... and indeed it was 
the reason for the issue.
I changed it to instantiate the attributes in the __init__ method of the class, 
and it solved the problems.
Thanks again !!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35339] Populating instances of class automatically

2018-11-28 Thread Geoffrey Spear


Geoffrey Spear  added the comment:

It's impossible to guess exactly what you did from your vague description 
instead of actual code, but it may be covered by this FAQ question: 
https://docs.python.org/3/faq/programming.html#why-are-default-values-shared-between-objects

(mutable objects as class rather than instance attributes will display similar 
behavior. This isn't a bug.)

--
nosy: +geoffreyspear

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35339] Populating instances of class automatically

2018-11-28 Thread Daugeras


New submission from Daugeras :

Hello, I am not sure it is a bug, but it is a very strange behavior of Python, 
which I do not understand.

I created a class (mainly a structure) and instantiated an object of this class 
in a first function (Object 1). The function populates Object 1.
In another function, I instantiate another object of the same class (Object 2) 
, and Object 2 is automatically populated with the data of Object 1. Note than 
Object 1 and Object 2 have different memory adresses.

This behavior is very strange. Is it normal for Python or is it a Bug ?

--
messages: 330613
nosy: Daugeras
priority: normal
severity: normal
status: open
title: Populating instances of class automatically
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com