# P7.6 Python Function साठी Docstring कसं लिहायचं?

Source: https://ravindrabagale.com/mr/datascience/py07-python-functions-tutorial-def-return-arguments-and-lambda/p7-6-how-to-write-a-docstring-for-a-python-function.html
Language: mr (Marathi with English technical terms)

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

सहा महिन्यांनी तुम्हालाच आठवणार नाही function काय करतं. Docstring ते सांगतो.

हे काय आहे?

def खालच्या पहिल्या line मधला """…""" text म्हणजे docstring. help() ने तो वाचता येतो.

कसं करायचं?

Step 1. def खाली """ लिहा.
Step 2. काय करतं, काय घेतं, काय देतं ते लिहा.

उदाहरण A: Document केलेलं cleaner function

```python
def clean_name(text):
    """Return a patient name with no outer spaces and Title Case."""
    return text.strip().title()

print(clean_name("  maria lopez "))
print(clean_name.__doc__)
```

Output:

```text
Maria Lopez
Return a patient name with no outer spaces and Title Case.
```

याचा अर्थ: help() ने docstring दिसला.

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

Docstring मध्ये एक स्पष्ट वाक्य काहीच नसण्यापेक्षा चांगलं. कल्पना ताजी असतानाच लिहा.
