# argparse

Пример

{% code title="module\_CLI.py" lineNumbers="true" %}

```python
import argparse

def main():
    # Создаем парсер аргументов командной строки
    parser = argparse.ArgumentParser(description='Пример использования argparse')

    # Добавляем аргументы
    parser.add_argument('--name', type=str, default='Мир', help='Приветственное сообщение с именем')
    parser.add_argument('--doublestr', type=str, help='удвоение строки')

    # Парсим аргументы
    args = parser.parse_args()

    # Используем аргументы
    if args.name != 'Мир': # если задана пустая строка -> default
        print(f'Привет, {args.name}!')# --name -> args.name
    if args.doublestr != None:
        print(f'{args.doublestr}'*2)

if __name__ == '__main__':
    main()

```

{% endcode %}

Запуск&#x20;

```
python module_CLI.py --doublestr abcd
```


---

# 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://autotests-pytest.gitbook.io/pytest/argparse.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.
