GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

python strings and representations

Andrew Sperazza python Englisch 15 Karten

Karten in diesem Stapel (15)

  1. 1what are the 2 string representations in python?str(obj) and repr(obj)
  2. 2how do you set str(obj) in your class__str__(self)
  3. 3how do you set repr(obj) for your class?__repr__(self)
  4. 4which should you always implement for your classes__repr__(self)
  5. 5who is __repr__ for?its primarily for developers
  6. 6what should you include in __repr__ ?include type
    make it precise and unambiguous
  7. 7if there is no __str__ what happens?__str__ by default falls back to use __repr__
  8. 8which representation does print() use?print uses str
  9. 9what does format use?format uses __format__(self,f)
  10. 10what module allows for drop in replacement for repr?import reprlib
    from reprlib import Repr
    reprlib.repr(obj)
  11. 11what does reprlib give you?it limits output size for large collectoins
  12. 12what function takes and returns a unicode string?s=ascii(string)
  13. 13how do you get an integer codepoint for a characterthe ord() function takes in single char unicode string and returns integer codepoint for that character
    i=ord(c)
  14. 14how do you get a single character from an integer code point?chr() takes in an integer codepoint and returns the single character string
  15. 15which 2 character functions are inverses of each other?ord() and chr() are inverses of each other

Informationen

Beschreibung
python (beyond basics python flashcards) Karteikarten am python strings and representations, erstellt von Andrew Sperazza am 10/01/2017.
Erstellt von
Andrew Sperazza
Aufrufe
5
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck