I have code like so:
import random
def helper():
c = random.choice([False, True]),
d = 1 if (c == True) else random.choice([1, 2, 3])
return c, d
class Cubic(object):
global coefficients_bound
def __init__(self, a = random.choice([False, True]),
b = random.choice([False, True]),
(c, d) = helper()):
...
...
The helper() function is introduced as I cannot have co-dependent arguments in the definition of the function itself - Python complains that it cannot find c when it's calculating d.
I want to be able to create an object of this class like so, changing a default argument:
x = Cubic(c = False)
But I get this error:
Traceback (most recent call last):
File "cubic.py", line 41, in <module>
x = Cubic(c = False)
TypeError: __init__() got an unexpected keyword argument 'c'
Is this possible with how I've written it? If not, what way should I do this?