0
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()
2 ответов
+ 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.
+ 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.