4 Python Surprises for Devs

This week I'm back to Python basics revising, building, and going deeper than tutorials usually take you. And honestly? Revisiting fundamentals hits different when you're actually building projects alongside them. Here are 4 Python things that surprised me (and most devs never know): 01 -> for loops have an else block It runs only if no break was hit. No need for a found = False flag ever again. 02 -> Dicts are ordered since Python 3.7 People still use OrderedDict out of habit. You haven't needed it for years. 03 -> _ stores your last REPL result Type 42 * 1000, then _ / 100 — it chains. The underscore is alive in the REPL. 04 -> zip() silently drops extra items If your two lists are different lengths, regular zip loses data without a warning. Use itertools.zip_longest with a fillvalue. The best way to remember tricks is to build something with them immediately. What Python thing surprised you when you first discovered it? Drop it below 👇 #Python #100DaysOfCode #Programming #SoftwareDevelopment #OpenToWork

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories