How do you create an incremental ID in a Python Class -


I would like to create a unique ID for each object I created - here's the class:

  class resource_cl: def __init __ (self, name, status, type, active): self.Name = name self.Position = position self.Type = type self Active = Active  

I should be on my own. The ID is that automatic increments every time I create a new reference for the class, such as:

  resources = [] resource .append (resource_cl ('Sam Sneed' , 'Programmer', 'full time', True))  

I know I can reference resource_cl, but I'm not sure how to proceed from there ...

Are you aware of Python, and can you use it in your counter Instead of the idea?

  class C (): pass x = C () y = C () print (id (x), id (y) # (4400352, 16982704)  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -