realpython / realpython/python-guide
Addition of specific example of great code from one of the listed repositories.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Batchfile
- Estrellas
- 29.8k
- Forks
- 5.9k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I absolutely love the Reading Code section, and I've been going through some of the repositories and identifying specific examples of why the code is good.
I was hoping to add one such example to the page. Specifically, from howdoi. It's virtually at the top of the codebase and it deals with standardizing the repository for Python 2 and 3.
https://github.com/gleitz/howdoi/blob/master/howdoi/howdoi.py
# Handle imports for Python 2 and 3
if sys.version < '3':
import codecs
from urllib import quote as url_quote
from urllib import getproxies
# Handling Unicode: http://stackoverflow.com/a/6633040/305414
def u(x):
return codecs.unicode_escape_decode(x)[0]
else:
from urllib.request import getproxies
from urllib.parse import quote as url_quote
def u(x):
return x
I think that there are two (and a half) key pedagogical takeaways from this.
The half takeaway is that supporting different versions of Python need not be a grueling task.
The remaining two are -
- Appropriate use of control flow for module imports and function creation
- Standardizing an API so that its source is indistinguishable to the rest of the code and functionality is consistent.
I haven't formally written this up yet, but if you think it would be a useful example, I can do that and submit a pull request.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la sección Reading Code y el ejemplo vinculado howdoi/howdoi.py. Redacta una explicación formal del manejo de imports de Python 2/3, el flujo de control y la API coherente descritos en el issue, y añádela a la página correspondiente. Se considerará completado cuando el ejemplo y sus conclusiones pedagógicas estén incluidos en un pull request.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- documentation
- Tipo de issue
- Documentación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100