파이썬[Python]: 내장함수 - __module__ 변수

내장함수 - __module__ 변수(variable)


/// 설명

클래스와 함수(메서드)가 포함되어 있는 모듈의 이름을 표현합니다. A Variable in Python Standard.
(Built-in 은 제공하지 않습니다.)

※ 형식
__module__

reference
https://docs.python.org/3/library/inspect.html

/// 예제

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import array
 
print(int.__module__)  # builtins
print(breakpoint.__module__)  # builtins
# print(array.array.index.__module__)  # Error: method_descriptor
 
 
class MyClass:
    def my_method(self):
        pass
 
 
print(MyClass.__module__)  # __main__
print(MyClass.my_method.__module__)  # __main__
 
 
def my_function():
    pass
 
 
print(my_function.__module__)  # __main__
 
# int.__module__ = 'int.____module____'  # Error
 
# it may be changed
__module__ = '__module__'
print(__module__)  # __module__
 
breakpoint.__module__ = 'breakpoint.____module____'
print(breakpoint.__module__)
 
MyClass.__module__ = 'MyClass.__module__'  # Error
print(MyClass.__module__)
 
MyClass.my_method.__module__ = 'MyClass.my_method.__module__'  # Error
print(MyClass.my_method.__module__)
 
my_function.__module__ = 'my_function.__module__'  # Error
print(my_function.__module__)
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

파이썬[Python]: 내장함수 - bit_length 메서드

C 언어: sin 함수, cos 함수, tan 함수