Pues si hice unas cuantas modificaciones, pero sigue fallando:
Código Python:
Ver originalimport random
#################################
#Movie
#Creamos la clase Movie
class Movie:
def __init__(self,title="emptyTitle",
director=["emptyDirector"],
cast = ["emptyCast"],
producer = ["emptyProducer"],
writer = ["emptyWriter"],
country = ["emptyCountry"],
language = ["emptyLanguage"],
year = "emptyYear",
genres = ["emptyGenres"],
votes = "emptyVotes",
rating = "emptyRating",
runtime = ["emptyRuntime"],
plot = ["emptyPlot"],
cover_url = "emptyCorver"):
self.title = title
self.director = director
self.cast = cast
self.producer = producer
self.writer = writer
self.country = country
self.language = language
self.year = year
self.genres = genres
self.votes = votes
self.rating = rating
self.runtime = runtime
self.plot = plot
self.cover_url = cover_url
def GetTitle(self):
return self.title
#################################
#función loadMovieList
def loadMovieList(filename):
peliculas = abrirarchivo(filename)
movieList = []
for peli in range(len(peliculas)):
pelicula = peliculas[peli].split("|")
p = Movie(pelicula[0],pelicula[1],pelicula[2],pelicula[3],pelicula[4],pelicula[5],pelicula[6],pelicula[7],pelicula[8],pelicula[9],pelicula[10],pelicula[11],pelicula[12],pelicula[13])
movieList.append(p)
movieList.sort()
return movieList
#################################
#Abrimos el archivo
def abrirarchivo(db):
file = open(db,"r")
peliculas = file.readlines()
file.close()
return peliculas
movieList = loadMovieList('peliculas100.dat')
#Reducimos la lista de peliculas a 21 elementos
movieList = movieList[0:20]
#################################
#Nodo
#Creamos la clase Nodo
class Node:
m = Movie()
lista = m.GetTitle()
def __init__(self,data=None):
self.lista = None
self.data = data
#################################
#Stack
#Creamos la clase Stack
class Stack:
def __init__(self):
pila = []
self.sList = pila
def push(self,node):
n = Node()
self.sList.append(n.data)
return True
def pop(self):
if self.isEmpty():
return "La pila esta vacia"
else:
return self.sList.pop()
def isEmpty(self):
return len(self.sList) == 0
def printStack(self):
print self.sList
return True
#################################
#Queure
#Creamos la clase Queure
class Queure:
def __init__(self):
cola = []
self.qList = cola
def enqueue(self,node):
self.qList.append(node)
return True
def dequeue(self):
if(self.isEmpty()):
return "La cola esta vacia"
else:
node = self.qList[0]
self.qList = self.qList[1:]
return node
def isEmpty(self):
return len(self.qList) == 0
def printQ(self):
print self.qList
return True
#################################
#Test de la clase Stack()
newStack = Stack()
newStack.printStack()
newNode = Node(movieList[0])
newStack.push(newNode)
newStack.printStack()
newStack.push(Node(movieList[1]))
newStack.printStack()
newStack.push(Node(movieList[2]))
newStack.printStack()
m1 = newStack.pop()
newStack.printStack()
m2 = newStack.pop()
newStack.printStack()
m3 = newStack.pop()
newStack.printStack()
m4 = newStack.pop()
newStack.printStack()
print m1.GetTitle()
print m2.GetTitle()
print m3.GetTitle()
##print m4.GetTitle() GUESS WHAT HAPPENS...
#################################
#Test de la clase Queure()
#newQ = Queue()
#newQ.printQ()
#newNode = Node(movieList[0])
#newQ.enqueue(newNode)
#newQ.printQ()
#newQ.enqueue(Node(movieList[1]))
#newQ.printQ()
#newQ.enqueue(Node(movieList[2]))
#newQ.printQ()
#m1 = newQ.dequeue()
#newQ.printQ()
#m2 = newQ.dequeue()
#newQ.printQ()
#m3 = newQ.dequeue()
#newQ.printQ()
#m4 = newQ.dequeue()
#newQ.printQ()
#print m1.GetTitle()
#print m2.GetTitle()
#print m3.GetTitle()
#print m4.GetTitle() GUESS WHAT HAPPENS...
A ver si me podéis guiar un poco.
bichomen