CyberSource / CyberSource/cybersource-rest-samples-python

__dict__ vs to_dict()

Aperta
#33 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Python
Stelle
29
Fork
34
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hey, this might be a strange thing to open an issue for, but I'm using the SDK to transition from Authorize.net AIM to CyberSource, and I noticed that all the examples use things like:

request.payment_information = payment_info.__dict__
# etc
message_body = json.dumps(request.__dict__)

instead of:

request.payment_information = payment_info
# etc
message_body = json.dumps(request.do_dict())

...even though the SDK provides to_dict() for a whole lot of things, so it looks like it was designed for that (and it avoids including unwanted attributes by accident). It looks like both ways produce the same output and work on the process_payment.py sample.

Is there a reason to prefer __dict__ each time over a single to_dict() at the end?

Thanks

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Iniziate con l’esempio process_payment.py e gli oggetti SDK che espongono to_dict(); confrontate i due percorsi di serializzazione descritti nell’issue. Il lavoro sarebbe completato con una raccomandazione confermata da un maintainer e, se gli esempi dovessero cambiare, con un aggiornamento della documentazione o dell’esempio chiaramente identificato; l’issue non indica alcun file di destinazione né alcun test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.