I was wondering if anyone could explain why these two examples end up giving the same result:
class Myclass(): def __init__ (self, parameter=None) if parameter is None: self.parameter = 1.0 else: self.parameter = parameter
and
class Myclass(): def __init__ (self, parameter=None) if parameter: self.parameter = parameter else: self.parameter = 1.0
I intuitively understand the first βif ... no,β but I am struggling with a second example. Are both suitable for use?
I understand that this can be a pretty simple question, so if someone can direct me to a reading that will help me understand the difference, that will be big.
Thanks!
source share