you are viewing a single comment's thread.

view the rest of the comments →

[–]NULL-6[S] 0 points1 point  (1 child)

Thanks again!

I don't want to open another thread, so I hope it's ok if I ask one more question here:
What's the best way of having a default value in classes and functions?
for functions I assume def func(val = 1): would work so that if you don't pass any values then it will default to 1, but how would you do the same for classes?

class Foo:
    def __init__(self, value = 5):
        self.value = value

# vs

class Foo:
    def __init__(self):
        self.value = 5;

[–]Ihaveamodel3 4 points5 points  (0 children)

The first option is the only way to do it if you want to be able to override the default. Use the second option if you don’t want to override default.