06 October 2014

Hackbright[1][0]: Dictionaries and Shell

Today was dictionary day. Dictionaries are what Python calls hashes and what other languages, perhaps more informatively refer to as associative arrays. Dictionary handling is similar to that of lists, but they differ form lists in one key (hahaha see what i did there?!) way. Dictionaries are constructed as a key (or keys) with an associated value. In a list, the "key" is the index. Dictionaries do not preserve order the way that a list does, but you can make a dictionary out of anything that is immutable.

This is a valid dictionary:
beverages = {'tea' : 'earl grey', 'coffee' : 'sumatran', 'beer' : 'hefeweizen', 'juice' : 'grapefruit'}

instead of having to somehow assign the key (in the beverages dictionary, those would be tea, coffee, beer, and juice) to a list and then index it to match the values (corresponding would be earl grey, sumatran, hefeweizen, grapefruit), you can directly search for 'tea' or 'coffee'. This is because in python, each of these words has an associated hash that is always the same. Searching through dictionaries is also faster than searching through lists. They're pretty neat and would have saved me so much time trying to cross reference between the different derived abundances for all of the different stars that I measured as part of my thesis.

We did two exercises today, which consisted of using dictionaries and their keys to display and then to take a chunk of text and figure out how often each word showed up. Pairing went well today, which was nice, and meant that we actually finished the assignments today. In the afternoon, we talked more about shell scripting, which continues to be my most favorite thing. We have to sign up for 5 minute tech talks, and I'm wondering if I should talk about that or if I should find something else so I can actually learn something new (as opposed to relying on shell scripting yet again). We also got divided up into groups and paired with and advisor. Once a week, we have one-on-one chats with our advisor and today was my day. I really appreciate how often Hackbright checks in on us. It felt like I spent a lot of grad school floating away on my own. Speaking of which, I need to really need to get over this grad school PTSD.

And in super unrelated news, no matter what happens in Hackbright, I have reached the pinnacle of success (and no, I'm not talking about my Ph.D):

I made it on Buzzfeed!



My friend sent me an instagram message telling me that one of my pictures was posted. And then I understood why I recently got a bunch of random followers. To be fair, we had mostly packed away our kitchen and I needed coffee. I decided that melting one of Ramona's sippy cups wasn't in anyone's best interest, so a mason jar was the best receptacle I had on hand to contain the coffee. When the coffee brewer didn't fit over the jar well, chopsticks were clearly the answer.


No comments: