# Bài 20. Package

Package là thư mục chứa các module và các tệp dữ liệu khác. Thư mục được gọi là Package trong Python phải chứa tệp có tên \_\_init\_\_.py . Tệp này có thể là một tệp trống hoặc ta có thể đặt mã khởi tạo cho package đó.

Thư mục có thể chứa các thư mục con và tệp; tương tự như vậy, một Package có thể có các package con và các module.

![Minh họa cấu trúc Package trong Python (nguồn programiz)](/files/-MK7ww1QRUV0NcEYxQ1j)

## Sử dụng Package

Ta có thể nhập các module từ các package bằng toán tử dấu chấm (.).&#x20;

Ví dụ: nếu chúng ta muốn nhập module **start** sau đó gọi hàm select\_difficulty() trong ví dụ trên, nó có thể được thực hiện như sau:

```python
import Game.Level.start
Game.Level.start.select_difficulty(2)
```

Cách khác, ta có thể viết lệnh gọi hàm ngắn hơn với phương thức import khác như sau:

```python
from Game.Level import start
start.select_difficulty(2)
```

Hoặc

```python
from Game.Level.start import select_difficulty
select_difficulty(2)
```


---

# Agent Instructions: 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://python.dainganxanh.com/chuong3/bai-20.-package.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.
