# P10.6 स्वतःचा Python Module कसा तयार करायचा?

Source: https://ravindrabagale.com/mr/datascience/py10-python-modules-pip-and-virtual-environments-venv-explained/p10-6-how-to-create-your-own-python-module.html
Language: mr (Marathi with English technical terms)

हे का शिकायचं?

Helper functions प्रत्येक notebook मध्ये copy करण्यापेक्षा एका file मध्ये ठेवा.

हे काय आहे?

कुठलीही .py file module असते. त्याच folder मधून import file_name ने तिची functions वापरता येतात.

कसं करायचं?

Step 1. helpers.py मध्ये functions लिहा.
Step 2. त्याच folder मध्ये import helpers करा.

उदाहरण A: स्वतःचा helper import करा

Input file helpers.py:

```text
def clean_city(s):
    return s.strip().title()

def money(x, symbol="₹"):
    return f"{symbol}{x:,.2f}"
```

```python
from helpers import clean_city, money
print(clean_city("  pUNE "))
print(money(1234.5, "£"))
```

Output:

```text
Pune
£1,234.50
```

याचा अर्थ: आपल्या file मधलं function इतर module सारखंच वापरलं.

रवींद्र बागले यांची tip

Jupyter मध्ये helpers.py बदलल्यावर kernel restart करा (किंवा `%load_ext autoreload` आणि `%autoreload 2` वापरा) म्हणजे नवा code load होतो.
