AI CodingThrive Editorial

25 prompts de IA para programar en Python

Los asistentes de Python pueden redactar código deprisa, pero un resultado útil es una función pequeña con tipos explícitos, ejemplos y pruebas. Estos prompts exponen los supuestos antes de escribir código.

14 min de lecturaActualizado el
Mesa de un programador de Python con portátil, cuaderno y formas abstractas de código.

La versión breve

  • Los asistentes de Python pueden redactar código deprisa, pero un resultado útil es una función pequeña con tipos explícitos, ejemplos y pruebas. Estos prompts exponen los supuestos antes de escribir código.
  • No pegues credenciales, datos privados de clientes ni repositorios propietarios completos en un asistente no autorizado. Ejecuta los comandos y las pruebas en tu propio entorno. Que un parche parezca correcto no demuestra que funcione.

Los asistentes de Python pueden redactar código deprisa, pero un resultado útil es una función pequeña con tipos explícitos, ejemplos y pruebas. Estos prompts exponen los supuestos antes de escribir código.

No pegues credenciales, datos privados de clientes ni repositorios propietarios completos en un asistente no autorizado. Ejecuta los comandos y las pruebas en tu propio entorno. Que un parche parezca correcto no demuestra que funcione.

Cómo usar esta colección

Elige la tarea más parecida a tu trabajo. Copia el prompt, sustituye la escena o el contexto de código genérico por tus datos y conserva las restricciones que te permitan evaluar el resultado. Cambia una variable cada vez para saber qué ha mejorado.

El método sigue la guía de ingeniería de prompts de GitHub Copilot: aporta contexto concreto y revisa el resultado, sin dar por correcta una primera respuesta bien presentada.

Prompts de diagnóstico

Este grupo se centra en el diagnóstico. Facilita tu código y el comando de pruebas antes de aceptar la respuesta.

1. Un importador de 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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

2. Una utilidad de normalización de fechas

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

3. Un analizador de registros

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

4. Un cliente HTTP con reintentos

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

5. Un informe de línea de comandos

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

6. Un detector de duplicados

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

7. Un renombrador de archivos

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

8. Una capa de validación de datos

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

9. Una tarea en segundo plano

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

CSV records passing through a Python validation workflow.

10. Una refactorización de notebook a módulo

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.

Revisión: Ejecuta la reproducción propuesta antes de aplicar un parche.

Prompts de implementación

Este grupo se centra en la implementación. Facilita tu código y el comando de pruebas antes de aceptar la respuesta.

11. Un importador de 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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

12. Una utilidad de normalización de fechas

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

13. Un analizador de registros

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

14. Un cliente HTTP con reintentos

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

15. Un informe de línea de comandos

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

16. Un detector de duplicados

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

17. Un renombrador de archivos

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

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

18. Una capa de validación de datos

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

19. Una tarea en segundo plano

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

20. Una refactorización de notebook a módulo

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.

Revisión: Revisa el diff para detectar cambios ajenos a la tarea y accesos a datos no previstos.

Prompts para probar casos límite

Este grupo se centra en probar los casos límite. Facilita tu código y el comando de pruebas antes de aceptar la respuesta.

21. Un importador de 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.

Revisión: Ejecuta las pruebas y, cuando sea posible, comprueba que fallen antes de aplicar la corrección.

22. Una utilidad de normalización de fechas

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.

Revisión: Ejecuta las pruebas y, cuando sea posible, comprueba que fallen antes de aplicar la corrección.

23. Un analizador de registros

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.

Revisión: Ejecuta las pruebas y, cuando sea posible, comprueba que fallen antes de aplicar la corrección.

24. Un cliente HTTP con reintentos

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.

Revisión: Ejecuta las pruebas y, cuando sea posible, comprueba que fallen antes de aplicar la corrección.

25. Un informe de línea de comandos

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.

Revisión: Ejecuta las pruebas y, cuando sea posible, comprueba que fallen antes de aplicar la corrección.

Qué comprobar antes de usar el resultado

No pegues credenciales, datos privados de clientes ni repositorios propietarios completos en un asistente no autorizado. Ejecuta los comandos y las pruebas en tu propio entorno. Que un parche parezca correcto no demuestra que funcione.

Si el resultado no resuelve la tarea, acorta el prompt y especifica el dato o la restricción que falta. Guarda la versión utilizada para poder reproducir el recurso final o el cambio de código.

Para seguir leyendo

Continúa con una guía relacionada

Llévalo a la práctica

Tu siguiente paso

¿Tienes una pregunta o una corrección?

Contactar con Thrive

Seguir leyendo

Más artículos del diario

Todos los artículos