Here are some of the things I learned this week:
Python
You should not set a parameter’s default to some mutable object.
- Since parameters are “passed by reference” in Python, when you modify the parameter set to an empty type, you actually change the default. This results in the next call to that function to use whatever “new” object you’ve created as the default for that parameter.
- It’s not obvious to me why the language behaves this way. This makes me think of James Powell’s Advanced Metaphors in Coding with Python; I wonder if there is a metaphor I’m missing here.
- This came from Chapter 8 in Fluent Python by Luciano Ramalho
Emacs
You can scroll the “other” window without putting point there.
- I like to split my Emacs screen a lot. When I’m working in window and referencing the other, sometimes I want to scroll the other window.
- I tried to use a keybinding I found,
C-M-v
andC-M-V
, to do the scrolling, but that didn’t work. I even tried defining these myself in myinit.el
file. - Ultimately, I settled on using
M=PageUp
andM-PageDown
, and I set these as macros on my keyboard.
QMK
You should not define “aliases” in an enum
.
- While trying to define macros in QMK, I was told that aliases for keycodes
should not be included in any custom keycode
enum
s. The proper way to define an alias is to use the#define
preprocessor directives. - I would like to dig into why this is the case, but it’s supposedly using some
C
macro to do so and I have a feeling this is a rabbit hole that I have no time for.