Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Pulling Search Results From NASAs Images API With Testing - Stream Notes for October 31 2020 LiveCoding

` youtube : https : //www.youtube.com/watch?v=S1fyhO76BW0 `

### Notes

Spent the stream working on my process to pull videos from the NASA Images API](https://images.nasa.gov/docs/images.nasa.gov_api_docs.pdf). I could have done a quick and dirty script, but my current practice is to do everything with [Test Driven Development . This was a perfect thing to practice on. It's small and straightforward. At the start, I wasn't sure how to test it. That's a code smell. After a bunch of kicking around, I got it setup nicely.

This is the general pattern :

#!/usr/bin/env python3

from random import randint

class LoopRunner():
    def __init__(self):
        self.counter = 1
    def run_until_you_see_2(self):
        random_num = randint(1, 10)
        print(f'Run: {self.counter} Got: {random_num}')
        if random_num != 2:
            self.counter = self.counter + 1
    def run_loop(self):
        killer = 0
        while killer != self.counter:
            killer += 1
if __name__ == '__main__':
    tr = LoopRunner()

The [TODO: Code shorthand span ] loop checks against an instance variable to see if it should keep going. It calls an external method if it should. That method updates the instance variable. In most examples, you see a [TODO: Code shorthand span ] flag being set. That would take another step in this case. I like it referencing the counter directly.

### Links From The Stream

- (Please) Stop Using Unsafe Characters in URLs - 20 Python libraries you aren’t using (but should) – O’Reilly - 3.1. If Statements — Hands-on Python Tutorial for Python 3 - A common way of managing configurations for multiple environments (and... - Beginning Java - Unit 4 Looping - While - Best way to handle dev/test/prod variables in Python? - Software Engineering... - Do-while Loops - Google Search: best way to handle configs in dev vs prod - Google Search: how do you test while loops - Google Search: py if in dict - Google Search: py md5 - Google Search: py tldextract - Google Search: python domain processing library name - Google Search: python encode url spaces in name - Google Search: python if - Google Search: python make a url safe with spaces - Google Search: python prevent making instance variables - Google Search: python sha256 - Google Search: python show error - Google Search: python sleep - Google Search: python tuple - Google Search: python urlencode - Google Search: unittest while loop - How to encode URLs in Python - How to Get Domain Name Information in Python - Python Code - images.nasa.gov_api_docs.pdf - Lab 9 - While loops and unit testing — Runestone Interactive Overview - Object Oriented Programming in Pyth: Class and Instance Variables - Programming - While Loop - PyPI: tldextract - Python - Tuples - Tutorialspoint - Python 3.3.7 Documentation: 21.6. urllib.request — Extensible library for opening URLs - Python 3.3.7 Documentation: 21.8. urllib.parse — Parse URLs into components - Python 3.9.0 Documentation: 4. More Control Flow Tools - Python 3.9.0 Documentation: 8. Compound statements - Python 3.9.0 Documentation: 8. Errors and Exceptions - Python 3.9.0 Documentation: collections — Container datatypes - Python 3.9.0 Documentation: Glossary - Python 3.9.0 Documentation: hashlib — Secure hashes and message digests - Python 3.9.0 Documentation: time — Time access and conversions - Python 3.9.0 Documentation: Tuple Objects - Python 3.9.0 Documentation: urllib.parse — Parse URLs into components - Python Tuple (With Examples) - qgis - Inserting %20 instead of a space as a string - Geographic Information... - Results for "the" - Stack Overflow: Check if a given key already exists in a dictionary - Stack Overflow: How to formally insert URL space (%20) using Python? - Stack Overflow: How to get MD5 sum of a string using python? - Stack Overflow: Prevent altering instance variable