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

Fabien • 1 year 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'}
[CG]Maxime • 1 year ago

Thank you, I've updated the playground.

jolindien • 1 year ago

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

Federico Ponzi • 1 year ago

Thanks, this was very interesting!

MathJason • 1 year 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.)

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

[CG]Maxime • 1 year ago

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

chossette • 1 year ago

Tx, many thing I did not known

Katie Clark • 8 months ago

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

maklai • 1 year ago

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

dhmoclex • 1 year ago

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

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