If you want to get better at Pandas, the hard part isn’t finding tutorials. It’s finding problems worth solving. Most exercises hand you a tidy little table of five rows and ask you to sum a column — which teaches you the syntax, but nothing about the job. For the last 3.5 years, I’ve written…
Once you import a Python module, a second import won’t reload it. That’s usually good. But what if you want to? (Common in development and debugging.) This forces the reload.
You import a Python module with the variable you’ll define, not a filename. “import mymod” tells Python to find mymod.py in each dir in sys.path. The first directory is ” (the empty string) — i.e., the directory where the program is running (i.e., not where it was defined).
Over my 30+ years teaching Python, I’ve included practice exercises in all of my courses. And when I started to teach Git and Pandas, I made sure to include practice exercises there, too. That’s because there’s no learning without practice. At least, there’s no effective learning. Frustration isn’t fun, but it’s a necessary part of…
I just got back from PyCon US. It was delightful; I saw old friends, met new ones, gave a tutorial on decorators, and spoke at the education summit. I’m a PyCon US sponsor, which means that I also had a booth, giving out T-shirts, books, stickers, and flyers about the LernerPython platform. Of course, the…
If you’re like me, then you’ve lately been exploring agentic coding, having AI write code on your behalf. What will be the impact on our work developing software? On hiring? On training? From what I can tell, the question isn’t whether we’ll be using agentic coding, but how we do so. Knowing how AI writes…
TL;DR: If you teach Python, then you should check out course-setup (https://pypi.org/project/course-setup/) at PyPI! I’ve been teaching Python and Pandas for many years. And while I started my teaching career like many other instructors, with slides, I quickly discovered that it was better for my students — and for me! — to replace them with…
Writing a Python module? Want to control which names are exported via “from .. import *”? Define __all__, a list of strings indicating which names will be exported via “import *”:
Using many names from a Python module? Import them all: Wait: This is usually a TERRIBLE idea! • Potential namespace collisions• Less readable code• Module upgrades affect globals in your program I know, it’s tempting — but don’t!
Python trick: 0 is falsy, 1 is truthy. Use this for even/odd checks: No need for “if n % 2 == 0” — just use the truthiness!