Thanks Michael, these shorts are awesome! Dict and set comprehension seem to get unnoticed.. however they are really powerful!
@mikeckennedy3 жыл бұрын
Thanks for the nice works on the project. And yes, they do get ignored but are super neat.
@ThePaulWilliams3 жыл бұрын
🤯 I've used list comprehensions extensively. Don't recall ever reading/hearing that you could do it for dicts or sets as well. Thanks, Michael!
@mikeckennedy3 жыл бұрын
Glad to add some tools to your toolbox Paul.
@10a3asd3 жыл бұрын
Amazing
@mikeckennedy3 жыл бұрын
Thanks!
@AuskeFlapTrap3 жыл бұрын
Thanks for this! I have only used list comprehension once in the ~1.5 years I've been programming, and it's always been mysterious to me. But I'm currently in the middle of rewriting something I rather badly (but it works) wrote to automate part of my job, and I think I'm going to incorporate some of these into it now that I'm a little more seasoned. I sort of learned python while writing the automation code, so there's a lot of things in it I want to clean up and make a little more robust.
@mikeckennedy3 жыл бұрын
Great, good luck on the refactoring/rewrite. No need to go totally crazy to use these everywhere. But when they make sense, it is very sweet.
@iamprageethanjula3 жыл бұрын
I have only used list comprehension. This is cool. BTW how actually list compression makes the code faster?
@mikeckennedy3 жыл бұрын
Thanks Prageeth. List comps *can* be faster because Python the runtime can see the intent is to create a list. Whereas a straight loop, could be doing anything, so has to run more generally.