28 lines
554 B
Python
28 lines
554 B
Python
movies = []
|
|
|
|
|
|
class Movie(object):
|
|
def __init__(self, name, sample_attr):
|
|
self.name = name
|
|
self.sample_attr = sample_attr
|
|
movies.append(self)
|
|
|
|
|
|
def create(name, sample_attr):
|
|
return Movie(name, sample_attr)
|
|
|
|
|
|
def update(name, set_sample_attr):
|
|
matches = [m for m in movies if m.name == name]
|
|
if len(matches) != 1:
|
|
raise LookupError(f"{matches}/{name} should be of length 1")
|
|
|
|
matches[0].sample_attr = set_sample_attr
|
|
|
|
return matches[0]
|
|
|
|
|
|
def _clear_movies():
|
|
while movies:
|
|
movies.pop()
|