Python right position for a Error message in a class first of all sorry for this easy question. I have a class

class Grid(object):
    __slots__= ("xMin","yMax","nx","ny","xDist","yDist","ncell","IDtiles")
    def __init__(self,xMin,yMax,nx,ny,xDist,yDist):
        self.xMin = xMin
        self.yMax = yMax
        self.nx = nx
        self.ny = ny
        self.xDist = xDist
        self.yDist= yDist
        self.ncell = nx*ny
        self.IDtiles = [j for j in np.ndindex(ny, nx)]
        if not isinstance(nx, int) or not isinstance(ny, int):
            raise TypeError("an integer is required for nx and ny")


where

xMin = minimum x coordinate (left border)
yMax = maximum y coordinate (top border)
nx = number of columns
ny = number of rows
xDist and yDist = resolution (e.g., 1 by 1)


nx and ny need to be an integer. I wish to ask where is the most elegant position for  the TypeError. Before all self. or in the end?
class Grid(object):
    __slots__= ("xMin","yMax","nx","ny","xDist","yDist","ncell","IDtiles")
    def __init__(self,xMin,yMax,nx,ny,xDist,yDist):


Python convention says that argument should be lowercase_with_underscores

        self.xMin = xMin
        self.yMax = yMax


The same convention holds for your object attributes

        self.nx = nx
        self.ny = ny
        self.xDist = xDist
        self.yDist= yDist
        self.ncell = nx*ny
        self.IDtiles = [j for j in np.ndindex(ny, nx)]


This is the same as self.IDtiles = list(np.ndindex(ny,nx))

        if not isinstance(nx, int) or not isinstance(ny, int):
            raise TypeError("an integer is required for nx and ny")


This would be more conventialy put at the top. But in python we prefer duck typing, and don't check types. You shouldn't really be checking the types are correct. Just trust that the user of the class will pass the right type or something close enough.