Comprehensions are among the most useful constructs in Python. They merge the old, trusty “map” and “filter” functions into a single piece of compact, elegant syntax, allowing us to expression complex ideas in a minimum of code. Comprehensions are one of the most important tools in a Pythonista’s toolbox. And ...
It’s really tempting, when you first start to use Python, to use “is” rather than “==”. It’s a bit more readable, and it feels like it should just work, especially when you’re dealing with integers. In a language that uses “or” and “and” instead of “||” and “&&”, it seems ...
If you’re a programmer, then you have likely heard about regular expressions (“regexps”) before. However, it’s also likely that you have tried to learn them, and have found them to be completely confusing. That’s not unusual; while regular expressions provide us with a powerful tool for analyzing text, their terse, ...
I’ll be giving another free one-hour Webinar about Python — this time, about the magic methods that Python offers developers who want to change the ways in which their objects work. We’ll start off with some of the simplest magic methods, but will quickly move onto some of the more ...
One of the basic data types that Python developers learn to use, and to appreciate, is the dictionary, or “dict.” This is the Python term for what other languages call hashes, associative arrays, hashmaps, or hash tables. Dictionaries are pervasive in Python, both in the programs that we write, and ...
Join me for an hour-long free Webinar about object-oriented Python on April 1st, 2015. I’ll discuss how to use and create classes in Python, how attributes form the core of Python’s object system, and how you should (and shouldn’t) think about Python’s objects. There will be plenty of time for ...