I am just starting to learn Python, but I have already run into some errors. I have made a file called pythontest.py with the following contents:
You need to do:
>>> import pythontest
>>> f = pythontest.Fridge()
Bonus: your code would be better written like this:
def __init__(self, items=None):
"""Optionally pass in an initial dictionary of items"""
if items is None:
items = {}
if not isinstance(items, dict):
raise TypeError("Fridge requires a dictionary but was given %s" % type(items))
self.items = items