... logging: introduction


This video has three files. To run it from the command line you need to be sure that you're in a virtualenv that has pandas installed.


import sys 

from summarise import summary

if __name__ == "__main__":
    # this line will grab the ticker argument
    ticker = sys.argv[1]

    # this line will take the ticker and do the analysis
    print(f"The average stock price is {summary(ticker)}")


from fetch import download_data

def summary(ticker):
    dataf = download_data()
    return dataf[ticker].mean()


import pandas as pd

def download_data():
    url = 'https://calmcode.io/datasets/stocks.csv'
    return pd.read_csv(url)

You'll notice that everything runs fine when we run;

python job.py KLM

But things go wrong when we run;

python job.py GOOG

The debugging could be made easier if we had logging around. Sure, we could also use the python debugger but logging is a good habbit either way. In this series of videos we're going to explain how to set it up.

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider signing up for the newsletter.