# 2019 Week 3

### Python

I have to thank Fluent Python for all of these tips and trick with Python.

You can implement dunder methods to make an object feel more Pythonic.

• Things like __repr__, __str__, __format__, __bytes__, __abs__, __bool__, __hash__, and __eq__.

You can extend the Format Specification Mini-language.

• There’s already quite a bit you can do with what is given to you. I think it’s cool that you can add new format specifications or I bet even override the standard ones.

You can make properties of an object read only.

• I think the code for doing this looks really slick.

• There’s a convention that any variable name that starts with an underscore is private in Python. But that’s just a Python people thing.

• So in your constructor, you would store any parameters as private variables. Then make a getter with the name of the variable, sans underscore. Decorate it with a @property - which I think is to mainly mark it as a getter? - and this makes the variables read only unless you really know what Python is doing.

### Emacs

You can find and replace across multiple files.

• I found this thing called dired. It was a little hard to use because the version of Emacs I’m running had a different function bound to the keyboard shortcut used in the docs.

• Here’s what I did:
  M-x find-dired
<pick the directory you want to search in>
Run find (with args): -name "*.json*"
t  # To select all files from the previous command
M-x dired-do-find-regexp-and-replace
<find regex>
<replace regex>

• I have Projectile installed in Emacs, so I could use the projectile-replace function to find and replace strings. I believe that the directory it looks in is the current project. Projectile defines any git repo as a project, so that shoulc cover like 90% of my use cases.

You can save multiple buffers at a time.

• The previous sentence is a bit misleading because you still have to save them one after another; though there is a key that saves them all.

• I used C-x s and it prompted me in the minibuffer for each file that needed to be saved.

• I believe that C-x s !` will save all with no prompt.

### QMK

The mouse keys are pretty simple to use.

• There are four navigation keys, five mouse buttons, and four scrolling keys.

• There are also three “set acceleration” buttons, but I’m not sure I noticed a difference in the acceleration when I was testing it.

### Thoughts

I don’t know how often I’ll use that “read-only” trick in my day to day work. I still think it’s a good pattern to know though. I’m a little surprised there isn’t some syntatic sugar to do it all in one step though. Or maybe that’s just the lazy part of me speaking.

Since I use Emacs all day, every day, it’s exciting to constantly be learning these little refinements to my workflow. I wonder how long it’ll be until I start twaeak every little thing to work how I want it to work.

Speaking of tweaking things, I decided to not tweak my keyboard this week. Instead, I just wanted to look into this feature: Mouse Keys. I think it’s a neat idea, I doubt it’s super practical, but it’ll raise some eyebrows when people see me crudely controlling my mouse from my keyboard.

Thanks for reading this post! Comments, questions, and feedback are always welcome.