We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Fabien • 6 years ago

Nice job, the examples are well chosen.

I would suggest that args2 should be renamed kwargs for consistency in "unpacking arguments":


print("Call function repeat using a dictionary of keyword arguments:")
kwargs = {'count': 4, 'name': 'cats'}
repeat(**kwargs)
[CG]Maxime • 6 years ago

Thank you, I've updated the playground.

jolindien • 6 years ago

I didn't know defaultdict ... really useful !
Thanks

Federico Ponzi • 6 years ago

Thanks, this was very interesting!

MathJason • 6 years ago

This was really great. I didn't know about the one line `tree()` hack, or the decorators `@contextmanager` or `@lru_cache`. Also, with the `@contextmanager` example, it may be more clear to add comments like this. (However, I understood it just fine, so I don't know if I am being to nitpicky.)

@contextmanager
def colored_output(color):
print("\033[%sm" % color, end="") # lines before the yield associated with __enter__ method
yield
print("\033[0m", end="") # lines after the yield associated with __exit__ method

[CG]Maxime • 6 years ago

You're right, a comment can be helpful. I've added your suggestion.

chossette • 6 years ago

Tx, many thing I did not known

anonymous • 3 years ago

its all true but how long have you guys known this "stuff" hu i know But we are all geting trolled by you know what never mind we already said too much bye BANNED TIK TOK

anonymous • 3 years ago

hi guys how would you guys know that this is true

Katie Clark • 5 years ago

Thanks for these demos! Really handy stuff, quite a few new things for me!

maklai • 6 years ago

Unpacking arguments example - it is more precise if args(line 6) is a tuple instead of a list.

dhmoclex • 6 years ago

Very very nice! :D
Thank you very much for your course!

I was especially amazed by the defaultdict tree and the cache decorator !

Thanks!