Python Script Creation
Create a professional Python script with error handling and CLI interface.
Prompt template
Create a professional Python script for [TASK DESCRIPTION]. **Requirements:** - Python version: [VERSION, e.g., 3.11+] - Required libraries: [LIBRARIES] - Input source: [CLI arguments/file/API/database] - Output format: [Console/file/JSON/CSV] **The script should include:** 1. **CLI Interface:** Argparse or Click for command-line arguments 2. **Configuration:** Environment variables and/or config file support 3. **Logging:** Structured logging with different log levels 4. **Error Handling:** Try/except with specific exception classes 5. **Type Hints:** Complete type annotations for all functions 6. **Documentation:** Docstrings in Google/NumPy style 7. **Main Logic:** [DESCRIPTION OF DESIRED FUNCTIONALITY] **Code Quality:** - Follow PEP 8 conventions - Use Pathlib instead of os.path - Implement context managers where useful - Write testable code with dependency injection Include a requirements.txt and a brief README.
Replace placeholders in [square brackets]: [TASK DESCRIPTION][VERSION, e.g., 3.11+][LIBRARIES][CLI arguments/file/API/database][Console/file/JSON/CSV][DESCRIPTION OF DESIRED FUNCTIONALITY]
How to use this template
Copy the prompt, replace the placeholders in square brackets with your details and paste it into the AI assistant of your choice. The more precise your details, the better the result.
Tips for better results
- Describe the desired functionality as precisely as possible
- Specify required libraries and Python version
- Ask for a pyproject.toml instead of setup.py
- Request pytest tests for the main functions
Suitable open models
The selection names current open models as a starting point for your own tests. It is not a measurement for this template.
Keywords: #python #scripting #cli #automation