Te damos la bienvenida a nuestra página web, ahora vas a encontrar la respuesta de lo que buscabas.
Ejemplo 1: qué es la clase init python
The __init__ function serves two main purposes.
The first is its used as a tool to pass
arguments inside of it but the difference is you can spread those
arguments to other functions located in the same class.
To do this you would place the word (self.) keyword in another function
followed by the arguments name. This allows the argument to be spread
down to that function.
The second purpose is it allows you to pass arguments to a
classwhen calling the class. Without this function inside the classwhen you call the classno arguments would be able to go inside getting
nothing inreturn.
Ejemplo 2: qué es __init__ en python
# If you are familiar with C++ or Java think of the __init__ method as a constructor.# It is the method that is being called when the class is called.In the following# example we will see how we can call the __init__ method
my_variable = MyClass()
Si crees que ha sido provechoso nuestro artículo, te agradeceríamos que lo compartas con el resto programadores y nos ayudes a dar difusión a nuestro contenido.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)