Book review: Think Like a Programmer
Note: I’m not being paid or receiving any kind of compensation for this review.
TL;DR: This is a very good book. If you are a software developer I highly recommend it!
Note: I’m not being paid or receiving any kind of compensation for this review.
TL;DR: This is a very good book. If you are a software developer I highly recommend it!
My primary debugging tool is to add print statements to my programs</confession_time>. Print statements are very easy to use and they work well for any simple scripts. But that’s the catch: if you’re debugging an application and/or a test file, print statements won’t be enough or will just not work (in the case if tests files).
I normally don’t use many shortcuts because it’s easier to just use my arrows and mouse to navigate than to memorize shortcuts but I am slowly realizing that the time spent on learning a new shortcut pays off.
You can add arguments to the command line when running python scripts by importing the sys module from Python’s standard library and using its argv function.
Given a nested dictionary like this:
dog_breeds = {
'Labrador Retriever': {'life_span': 14, 'male_weight': '36 Kg', 'female_weight': '32 Kg'},
'Beagle': {'life_span': 15, 'male_weight': '11 Kg', 'female_weight': '10 Kg'},
'German Shepherd': {'life_span': 13, 'male_weight': '40 Kg', 'female_weight': '32 Kg'},
'Jack Russell Terrier': {'life_span': 16, 'male_weight': '8 Kg', 'female_weight': '8 Kg'},
'Rottweiler': {'life_span': 10, 'male_weight': '60 Kg', 'female_weight': '48 Kg'}
}
here’s a way to display its content sorted by key: