I have read several documentation already but the definition of “class” and “instance” didnt get really clear for me yet.
Looks like that “class” is like a combination of functions or methods that return some result is that correct? And how about the instance? I read that you work with the class you creat trough the instance but wouldnt be easier to just work direct with the class?
Sometimes geting the concepts of the language is harder than working with it.
Your question is really rather broad as classes and instances/objects are vital parts of object-oriented programming, so this is not really Python specific. I recommend you buy some books on this as, while initially basic, it can get pretty in-depth. In essense, however:
So you would, for example, define a
Dogclass, and create instances of particular dogs:While this example is silly, you can then start seeing how you might define a
Clientclass that sets a blueprint for what a Client is, has methods to perform actions on a particular client, then manipulate a particular instance of a client by creating an object and calling these methods in that context.Sometimes, however, you have methods of a class that don’t really make sense being accessed through an instance of the class, but more from the class itself. These are known as static methods.