GoConqr has a new look! Let us know what you think.

Flashcards

python strings and representations

Andrew Sperazza python English 15 cards

Cards in this deck (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

Information

Description
python (beyond basics python flashcards) Flashcards on python strings and representations, created by Andrew Sperazza on 10/01/2017.
Created by
Andrew Sperazza
Views
5
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?