Init 클래스 파이썬은 무엇입니까

코드 예제

8
0

파이썬에서__init__은 무엇입니까

# 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()
7
0

init 클래스 파이썬은 무엇입니까

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 
class when calling the class. Without this function inside the class
when you call the class no arguments would be able to go inside getting
nothing in return.

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................