I have the following classes:
class Contenedor:
def __init__(self, nserie, categoria, peso):
self._nserie = nserie
self._categoria = categoria
self._peso = peso
@property
def categoria(self):
return self._categoria
@property
def peso(self):
return self._peso
class Patio:
def __init__(self, cantSitios, cantContenedores):
self._sitios = [None] * cantSitios
self._pLibreSitios = 0
self._almacenamiento = []
for i in range(cantSitios):
self._almacenamiento.append([None] * cantContenedores)
A patio class, which has as attributes an arrangement of places (places), and a storage matrix that will allow me to store containers (class Container) in a certain position associated with a site
I'm trying to do the following method to add containers to the matrix
def agregarContenedor(self, cont, nSitio):
busqSitio = self.buscarSitio(nSitio)
if busqSitio != -1:
for j in range(len(self._almacenamiento[busqSitio])):
if self._almacenamiento[busqSitio][j] is None and self._almacenamiento[busqSitio][j]._nserie != cont._nserie:
self._almacenamiento[busqSitio][j] = cont
else:
return -1
else:
return -1
The method itself is adding a container (cont) verifying that the site named nSite is found, in addition to the container being added in a position where space is available (be None). In addition you must verify that the serial number of the container to be added, is not repeated in the matrix, the latter I am trying to do with the line self._storage [siteSearch] [j] ._ nserie! = Cont._nserie but in doing so, I an error 'NoneType' object has no attribute '_nserie
Does anyone know how to fix it ?, I'm starting in Python and I do not understand where the error may be. Thanks in advance