O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

python strings and representations

Andrew Sperazza python Inglês 15 flashcards

Flashcards do conjunto (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

Informações

Descrição
python (beyond basics python flashcards) FlashCards sobre python strings and representations, criado por Andrew Sperazza em 10-01-2017.
Criado por
Andrew Sperazza
Visualizações
5
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?