0

I am creating a python program in which a class has the attribute ID, and I want that ID to be unique and follow a pattern with each new object. I am struggling to figure out a way to do this. If possible, I want the ID code of each object to be relative to its creation order. (so "0-00-000-0000" for the first object). Each additional object of the same class should have an ID that is increased by one from the previous object. This program will eventually run as a time-focused simulation. I am a bit out of my league, but I am using this program as my first major, long-term project for self-teaching.

Is it possible to give incremental properties like this to objects of the same class, and even different classes? For example, if I had a subclass of the one mentioned above, could I design a way to make the ID code of its first object = "1-00-000-0000"? This is the pattern I'd like to follow, but I realize there may be a lot of hiccups in using something like this. Any help to get me started will be greatly appreciated, and I apologize in advance if I am posting a duplicate or something out of place. I'm new here and trying to learn.

Edit: I saw a couple of other questions that were similar, but they do not really help with what I'm trying to accomplish. I want to establish my own naming system for objects that uses my format and structure.

  • 2
    Related: [How do you create an incremental ID in a Python Class](//stackoverflow.com/q/1045344) – Aran-Fey Mar 16 '19 at 19:13
  • 1
    Possible duplicate of [How do you create an incremental ID in a Python Class](https://stackoverflow.com/questions/1045344/how-do-you-create-an-incremental-id-in-a-python-class) – Morten Kristensen Mar 16 '19 at 19:25

0 Answers0