Addition of specific example of great code from one of the listed repositories.
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 42/100
- Type d'issue
- Documentation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- documentation
Piste de recherche
Commencez par la section Reading Code et l’exemple lié howdoi/howdoi.py. Rédigez une explication formelle de la gestion des imports de Python 2/3, du flux de contrôle et de l’API cohérente décrits dans l’issue, puis ajoutez-la à la page appropriée. Le travail sera considéré comme terminé lorsque l’exemple et ses enseignements pédagogiques seront inclus dans une pull request.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Batchfile
- Étoiles
- 29.8k
- Forks
- 5.9k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de realpython/python-guide
-
Page 404 error Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
realpython/python-guide#1104 · 2 commentaires ·
-
Difficulté 1/5 1-3 heures Accessibilité débutants 62/100
realpython/python-guide#327 ·
-
PyZMQ improvements Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
realpython/python-guide#326 · 5 commentaires ·
-
@alex Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 10/100
realpython/python-guide#1194 ·
-
Development Team SAP Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 10/100
realpython/python-guide#1192 ·
Toutes les issues de realpython/python-guide
Issues similaires
-
Link Checker Report Ouverteautomated issue report
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
felladrin/uo-is-not-dead#176 · 1 commentaire ·
-
Add link for tutorial Ouvertedocumentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
Qiskit/qiskit-addon-sqd#376 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Seeed-Studio/wiki-documents#5655 · 2 commentaires ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
MystenLabs/sui#28056 · 1 commentaire ·