Python class = class()

What exactly does this do? I’ve read that its meant to initialize the class, but I’m not completely sure. Is it similar to importing a class from another file and then using it? https://www.sololearn.com/learn/738/ ^^^ A link to where I found NeuralNetwork = NeuralNetwork()

20th Mar 2020, 7:34 AM
Appl3s - avatar
2 Answers
+ 1
In the above example, network = neural_network() -means that you have defined an instance of class named network. It's there in the Python course here on SL but I understand OOP can be confusing for beginners. So here's a simple example Consider that there is a class named Dog. Now this class refers to all dogs all over the world. Then you do- dog1 = Dog() Now this makes an instance of class Dog named dog1. Now dog1 refers to a specific dog. You can make multiple dogs dog2 = Dog() dog3 = Dog() All of these will refer to single dogs which are of class Dog.
20th Mar 2020, 7:52 AM
XXX - avatar
+ 4
you are right, it is initialization but has nothing to do with import. It is simply creating an instance of a class. Please.. . your question is related to a lesson and better placed there in discussion section.
20th Mar 2020, 7:55 AM
Oma Falk
Oma Falk - avatar