Classes in Python

Question :

Classes in Python,

Answer :

In Python is there any way to make a class, then make a second version of that class with identical dat,a but which can be changed, then reverted to be the same as the data in the original class?

So I would make a class with the numbers 1 to 5 as the data in it, then make a second class with the same names for sections (or very similar). Mess around with the numbers in the second class then with one function then reset them to be the same as in the first class.

Read More  Fatal warnings on Windows

The only alternative I’ve found is to make one aggravatingly long class with too many separate pieces of data in it to be readily usable.


A class is a template, it allows you to create a blueprint, you can then have multiple instances of a class each with different numbers, like so.

class dog(object):      def __init__(self, height, width, lenght):          self.height = height          self.width = width          self.length = length        def revert(self):          self.height = 1          self.width = 2          self.length = 3    dog1 = dog(5, 6, 7)  dog2 = dog(2, 3, 4)    dog1.revert()  

That’s the answer Classes in Python, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Most efficient way to concatenate strings?

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you