-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
63 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# [self의 이해] | ||
# ** self는 인스턴스 객체이다!! | ||
# ** 클래스 안에 있는 self의 주소와 만들어진 인스턴스의 주소는 같다! 즉, self는 인스턴스 그 자체이다! | ||
|
||
|
||
class SelfTest: | ||
|
||
# * 클래스 변수 | ||
name = "amamov" | ||
|
||
def __init__(self, x): | ||
self.x = x # * 인스턴스 변수 | ||
|
||
# * 클래스 메서드 | ||
@classmethod | ||
def function1(cls): | ||
print(f"cls : {cls}") | ||
print("function 1 called !") | ||
|
||
# *인스턴스 메서드 | ||
def function2(self): | ||
print(f"self : {self}") | ||
print("class안의 self의 주소:", id(self)) | ||
print("function 2 called !") | ||
|
||
|
||
test_instance = SelfTest(17) | ||
|
||
|
||
print("인스턴스의 주소:", id(test_instance)) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# [self의 이해] | ||
# ** self는 인스턴스 객체이다!! | ||
# ** 클래스 안에 있는 self의 주소와 만들어진 인스턴스의 주소는 같다! 즉, self는 인스턴스 그 자체이다! | ||
|
||
|
||
class SelfTest: | ||
|
||
# * 클래스 변수 | ||
name = "amamov" | ||
|
||
def __init__(self, x): | ||
self.x = x # * 인스턴스 변수 | ||
|
||
# * 클래스 메서드 | ||
@classmethod | ||
def function1(cls): | ||
print(f"cls : {cls}") | ||
print("function 1 called !") | ||
|
||
# *인스턴스 메서드 | ||
def function2(self): | ||
print(f"self : {self}") | ||
print("class안의 self의 주소:", id(self)) | ||
print("function 2 called !") | ||
|
||
|
||
test_instance = SelfTest(17) | ||
|
||
|
||
print("인스턴스의 주소:", id(test_instance)) |