> For the complete documentation index, see [llms.txt](https://sdc-james.gitbook.io/onebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sdc-james.gitbook.io/onebook/3./3.7.-modules/3.7.3.-dir.md).

# 4.7.3.      dir( ) 함수

dir() 내장 함수는 모듈에 정의된 이름들을 정렬된 문자열목록으로 반환합니다. 이 목록에는 모듈에 정의된 모든 모듈, 변수 및 함수의 이름이 들어 있습니다.

```python
 content = dir()
 print("Basic =")
 print(content)

 from math import sin
 content = dir()
 print("from math import sin = ")
 print( content)

 from math import *
 content = dir()
 print("from math import *  = ")
 print(content)

 import math
 content = dir()
 print("After import math = ")
 print(content)

 content = dir(math)
 print("math module name ")
 print(content)
```

위의 코드가 실행되면 다음과 같은 결과 화면을 볼 수 있습니다.

```
Basic =
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
from math import sin =
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'content', 'sin']
from math import *  =
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'content', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
After import math =
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'content', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'math', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
math module name
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc']
```

모듈을 임포트하는 가장 좋은 방법 또는 일반적으로 권장되는 스타일은 ‘import 모듈명’을 사용하고, 모듈 내의 함수 또는 변수를 사용할 때는 ‘모듈명.함수명(변수)’의 형태를 사용하는 것입니다.

모듈을 파이썬 스크립트로 가져오면 모듈의 최상위 레벨에 있는 코드가 한 번만 실행됩니다.

모듈의 최상위 코드를 다시 실행하려면 reload() 함수를 사용할 수 있습니다. reload() 함수는 이전에 가져온 모듈을 다시 가져옵니다.  reload() 함수의 구문은 다음과 같습니다.

**reload (module\_name)**

여기서 module\_name은 다시 로드하려는 모듈의 이름입니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdc-james.gitbook.io/onebook/3./3.7.-modules/3.7.3.-dir.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
