Some of the most satisfying work I do happens one on one. You arrive with a real problem from your real job — code that will not behave, an architecture you are unsure about, a Git situation that has you stuck — and an hour later it is smaller, or gone. I have offered these…
Missing data in Python Pandas? We use nan (“not a number”), which comes from NumPy. np.nan is a float, but not a normal one:
What is a “callable” in Python? Typically, a function or class. But really, it’s anything with __call__ defined: The “callable” builtin basically returns True if it finds __call__.
If you invoke +=, Python can use __add__. MyClass implements __add__ (calling print for debugging): m1 now refers to a new object, and its repr is: MyClass instance, vars(self)={‘x’: 30}
How does the “in” operator work in Python? – If an object defines __contains__, then its (boolean) result is returned (coerced to bool).– If not, then Python iterates over it with __iter__ Can you find and return a result faster than __iter__? Then define __contains__.
I really enjoy reading e-mail newsletters. They’re clever, informative, and funny, and provide me with lots of food for thought — as well as professional information that is crucial to my work. The thing is, I don’t have time to read them during the week. And on Saturday, when I do have time, I don’t…
In Python, we use “or” for conditions. | is bitwise (not boolean) “or”: x | y # 15, or 0b1111 | runs __or__. On dicts, | combines.
The % in Python, on numbers, is modulo: But str uses __mod__ for interpolation: Same operator, same magic method — but totally different.
Just as + in Python invokes __add__, other operators invoke other magic methods: • – is __sub__• * is __mul__• / is __truediv__• // is __floordiv__• % is __mod__• ** is __pow__ Your methods can do whatever you want. But do try to stick to conventional expectations.
I’ve been using Claude Code several hours a day for months, and I’m having a blast. But an agent does what you tell it, not what you meant — which is why validating your results now matters more than the results themselves.