Reputation: 37
im trying to build a matix class for practice, and i was wondering, suppose I define a matrix with the arguements "rows" and "columns".
is there a way to set "columns" to be "rows" as default?
example:def __init__(self, rows, columns = rows)
i tried to compile but it gives me the "unresolved refence" error
thank you
Upvotes: 3
Views: 40
Reputation: 1848
This does not work. But you can set None
as default and check for that in the method's body, e.g.
def __init__(self, rows, columns=None):
if columns is None:
columns = rows
# do something
Upvotes: 5