AI CodingThrive Editorial

25 prompts d’IA pour programmer en Python

Un assistant peut écrire rapidement du Python, mais le résultat utile est une petite fonction accompagnée de types explicites, d’exemples et de tests. Ces prompts font apparaître les hypothèses avant l’écriture du code.

14 min de lectureMise à jour
Bureau de développeur Python avec ordinateur portable, carnet et formes abstraites de code.

La version courte

  • Un assistant peut écrire rapidement du Python, mais le résultat utile est une petite fonction accompagnée de types explicites, d’exemples et de tests. Ces prompts font apparaître les hypothèses avant l’écriture du code.
  • Ne transmettez jamais d’identifiants, de données client privées ou de dépôts propriétaires complets à un assistant non autorisé. Exécutez les commandes et les tests proposés dans votre environnement. Un correctif plausible ne prouve pas que la modification fonctionne.

Un assistant peut écrire rapidement du Python, mais le résultat utile est une petite fonction accompagnée de types explicites, d’exemples et de tests. Ces prompts font apparaître les hypothèses avant l’écriture du code.

Ne transmettez jamais d’identifiants, de données client privées ou de dépôts propriétaires complets à un assistant non autorisé. Exécutez les commandes et les tests proposés dans votre environnement. Un correctif plausible ne prouve pas que la modification fonctionne.

Comment utiliser cette collection

Choisissez la tâche la plus proche de votre travail. Copiez le prompt, remplacez la scène ou le contexte générique par vos informations et conservez les contraintes utiles pour évaluer le résultat. Modifiez une variable à la fois afin d’identifier ce qui s’améliore.

Cette méthode reprend les recommandations du guide de prompt engineering de GitHub Copilot : fournir un contexte précis et vérifier la réponse, sans supposer qu’un premier résultat soigné est correct.

Prompts de diagnostic

Cette série porte sur le diagnostic. Fournissez votre code et votre commande de test avant de valider la réponse.

1. Un importateur CSV

Help with a CSV importer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

2. Un utilitaire de normalisation des dates

Help with a date normalization utility in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

3. Un analyseur de journaux

Help with a log parser in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

4. Un client HTTP avec nouvelles tentatives

Help with a retrying HTTP client in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

5. Un rapport en ligne de commande

Help with a command-line report in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

6. Un détecteur de doublons

Help with a duplicate detector in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

7. Un outil de renommage de fichiers

Help with a file renamer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

8. Une couche de validation de données

Help with a data validation layer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

9. Une tâche en arrière-plan

Help with a background task in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

CSV records passing through a Python validation workflow.

10. Une refactorisation de notebook en module

Help with a notebook-to-module refactor in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

Prompts de mise en œuvre

Cette série porte sur la mise en œuvre. Fournissez votre code et votre commande de test avant de valider la réponse.

11. Un importateur CSV

Help with a CSV importer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

12. Un utilitaire de normalisation des dates

Help with a date normalization utility in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

13. Un analyseur de journaux

Help with a log parser in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

14. Un client HTTP avec nouvelles tentatives

Help with a retrying HTTP client in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

15. Un rapport en ligne de commande

Help with a command-line report in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

16. Un détecteur de doublons

Help with a duplicate detector in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

17. Un outil de renommage de fichiers

Help with a file renamer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

Three-step code workflow: brief the work, inspect the result, edit and verify.

18. Une couche de validation de données

Help with a data validation layer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

19. Une tâche en arrière-plan

Help with a background task in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

20. Une refactorisation de notebook en module

Help with a notebook-to-module refactor in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

Prompts de test des limites

Cette série porte sur les tests de limites. Fournissez votre code et votre commande de test avant de valider la réponse.

21. Un importateur CSV

Help with a CSV importer in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

22. Un utilitaire de normalisation des dates

Help with a date normalization utility in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

23. Un analyseur de journaux

Help with a log parser in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

24. Un client HTTP avec nouvelles tentatives

Help with a retrying HTTP client in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

25. Un rapport en ligne de commande

Help with a command-line report in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

Que vérifier avant d’utiliser le résultat

Ne transmettez jamais d’identifiants, de données client privées ou de dépôts propriétaires complets à un assistant non autorisé. Exécutez les commandes et les tests proposés dans votre environnement. Un correctif plausible ne prouve pas que la modification fonctionne.

Si le résultat ne répond pas à la tâche, raccourcissez le prompt et précisez l’information ou la contrainte manquante. Conservez la version utilisée pour pouvoir reproduire le visuel final ou la modification du code.

Pour aller plus loin

Poursuivre avec un guide associé

Mise en pratique

Votre prochaine étape

Vous avez une question ou une correction?

Contacter Thrive

Continuez à lire

Pour en savoir plus sur le journal

Tous les articles
25 prompts d’IA pour programmer en Python | Thrive