307 time = time.time # type: ignore[union-attr] # mypy doesn't filter correctly
308 if isinstance(time, Time):
309 time_ref = time_ref if time_ref is not None else time._time_ref
310 time = time._time311 if isinstance(time, _data_base_types):
312 pass
313 elif isinstance(time, pint.Quantity):
306 if issubclass(type(time), TimeDependent):
307 time = time.time # type: ignore[union-attr] # mypy doesn't filter correctly
308 if isinstance(time, Time):
309 time_ref = time_ref if time_ref is not None else time._time_ref310 time = time._time
311 if isinstance(time, _data_base_types):
312 pass
Accessing a protected member (a member prefixed with _
) of a class from outside that class is not recommended, since the creator of that class did not intend this member to be exposed. If accesing this attribute outside of the class is absolutely needed, refactor it such that it becomes part of the public interface of the class.
class Rectangle(object):
def __init__(self, height, width):
self._height = height
self._width = width
r = Rectangle(4, 8)
area = r._height * r._width
class Rectangle(object):
def __init__(self, height, width):
self._height = height
self._width = width
def area():
return self._height * self._width
r = Rectangle(4, 8)
area = r.area()