B
B
Boris192017-09-26 13:36:38
Python
Boris19, 2017-09-26 13:36:38

How to use shared data for multiple objects?

It is required to create several objects of the same type, each of which has a certain field, which must be different for all objects. The problem is that these objects are created at different times and from different parts of the program. How to track the uniqueness of such fields in objects? If you make a static array in the class itself, and add a unique field of already existing objects to it? Or is it better to keep a separate list of these fields, but then this list will have to be carried everywhere with you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2017-09-26
@Boris19

An array for some reason - usually an auto-increment field is dispensed with. Declare it as a classproperty and increment it in __init__()

K
Konstantin Nagibovich, 2017-09-26
@nki

Have you heard about GUID?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question