bjotta
bjotta

Reputation: 49

Initating variables in Python

class Grid:
    def __init__(self, cellNum, cellData):
        self.cellNum, self.cellData = cellNum, cellData

I am new to python and wondering if there is any more clearer way to write this? I am trying to solve a nonogram and therefore needs to understand this part.

Upvotes: 0

Views: 79

Answers (1)

Radu Gheorghiu
Radu Gheorghiu

Reputation: 20509

You can break up the initialisation line, but I think the code can't get clearer than that:

class Grid:
    def __init__(self, cellNum, cellData):
        self.cellNum = cellNum
        self.cellData = cellData

Upvotes: 4

Related Questions