Get 10-day forecast script I coded a script to print a 10-day forecast for any location to my terminal. 

As I am just learning Python (coming from the PHP world - yes, I know...) and have no buddies coding in Python, I would really appreciate it if anyone could review my code and provide comments and suggestions for improving it. 

For starters, I know I am missing docstrings but I left that part for later as I am still reading about it.

Not sure if I need to mention it, but lookup_by_location() and _call() are overriding methods from Weather ancestor class.

Code is also available in a git repo.

#! /usr/bin/env python
import argparse
import requests
from weather import Weather
from weather import models

class WeatherReport(Weather):
    def __init__(self, location):
        Weather.__init__(self)
        self.get_report(location)   

    def get_report(self, location): 
        self.show_location(location)
        [self.show_weather(day) for day in self.get_days(self.lookup_by_location(location))]

    def lookup_by_location(self, location):
        url = "%s?q=select* from weather.forecast " \
              "where woeid in (select woeid from geo.places(1) where text='%s') and u='c' &amp;format=json" % (self.URL, location)
        results = self._call(url)
        return results

    def get_days(self, place):
        days = []
        [self.get_day(days, item['date'], item['low'], item['high'], item['text']) for item in place.forecast()]
        return days

    def get_day(self, days, date, low, high, text):
        days.append([date, int(low), int(high), text])

    def show_weather(self, day):
        from_to = "%d-%d" % (day[1], day[2])
        print " "*2 + "%s:" % (day[0]), from_to.rjust(5) + u'\u00b0' + "C -", "%s" % (day[3])

    def show_location(self, location):
        print "-" * 50
        feedback = "10-day forecast for " + location.capitalize()
        print feedback.center(50)
        print "-" * 50

    def _call(self, url):
        results = requests.get(url).json()
        if int(results['query']['count']) &gt; 0:
            wo = models.weather_obj.WeatherObject(results['query']['results']['channel'])
            return wo
        else:
            print 'No results found.'
            quit()


if __name__ == "__main__":
    parser = argparse.ArgumentParser('tdwreport')
    parser.add_argument('-l', '--location', default="sarajevo", help='get forecast for this location')
    parser.add_argument('-v', '--version', action='version', version='%(prog)s 0.2')
    args = parser.parse_args()
    report = WeatherReport(args.location)
One tip: Instead of gluing constant and variable parts into string with + as e. g. in your statement

print " "*2 + "%s:" % (day[0]), from_to.rjust(5) + u'\u00b0' + "C -", "%s" % (day[3])


use the format() method with placeholders {} in formatted string:

print "  {} {:&gt;5}{}C - {}"     .format(day[0], from_to, u'\u00b0', day[3])


(I visually separated the resulting string with placeholders from the format() method),
or - more descriptively - use names in {} placeholders

print "  {day0} {from_to:&gt;5}{degree_sign}C - {day3}" \
    .format(day0=day[0], from_to=from_to, degree_sign=u'\u00b0', day3=day[3])


Format specifier &gt;5 after : does the same thing as .rjust(5) in your code.



Edit:

For Unicode symbols (as u'\u00b0' in your code) use their hexadecimal value (0x00b0) and type c in the placeholder:

print "  {} {:&gt;5}{:c}C - {}"     .format(day[0], from_to, 0x00b0, day[3])


See Format Specification Mini-Language