Python: print() durch ic() ersetzen
Hier ein paar Beispiele, wie man mit icecream print() Ausgaben ersetzen kann.
""" icecream examples """ from icecream import ic # define some function def addiere(x, y): return x + y # call ice ic(addiere(1, 2)) # Output: # ic| addiere(1, 2): 3 d = {'i': 2, 'j': 3, 'k': 4711} ic(d['k']) struct = { "hersteller": "VW", "modell": "Golf", "Farben": ["gelb", "rot"] } ic(struct) ic.disable() ic(struct) # no output ic.enable() def logstuff(text): # log to output file print(text) ic.configureOutput(prefix="Hallo| ", outputFunction=logstuff) ic(addiere(7, 7)) ic.configureOutput(prefix="Welt| ", outputFunction=logstuff) ic(addiere(7, 7)) |