exec
Peter Otten
__peter__ at web.de
Fri Mar 2 02:26:13 EST 2012
Prasad, Ramit wrote:
> Hi Peter,
>
> >>> class Magnitude(object):
>
> ... def __init__(self, value):
> ... self.value = value
> ... def __call__(self, uf=1):
> ... if uf == 1:
> ... return self
> ... return self.value
> ...
>
> >>> class Iron(object):
>
> ... def __init__(self):
> ... self.rho = Magnitude(42)
> ...
>
>
> Why did you make uf=1 instead of None?
>
> ... def __call__(self, uf=None):
> ... if uf is None:
That's a design decision of the OP. I suggested an improvement of the
implementation and left the interface alone.
More information about the Python-list
mailing list