I'm a coder who's relatively new to Python and I wanted to spice up my console applications a bit by making animations. The code I've written works perfectly, but I just wanted to know if it was good in a pythonic way and if it follows the OO standards. If not please tell me what could be improved and why.
import subprocess as sp
import time
class Animation(object):
def __init__(self):
self.frames = []
def add_frame(self,frame):
#Adds frame to end of list
self.frames.append(frame)
def remove_last_frame(self):
#Removes last frame in list
del self.frames[-1]
def clear_frames(self):
#Deletes all frames
del self.frames[:]
def get_frames(self):
#Returns list of frames
return self.frames
def run_animation(self,loops,fps):
#Runs the animation at a desired framerate and loops it a given amount of times
delay = 1.0/fps
for x in range(0,loops):
for frame in self.frames:
#The following line clears the shell
tmp = sp.call('clear',shell=True)
print frame
time.sleep(delay)