Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def compass(self):
"""Return the compass direction, e.g., "N", "ESE", etc.)."""
if not self._compass:
degrees = 22.5 * round(self._degrees / 22.5)
if degrees == 360.0:
self._compass = "N"
else:
for name, d in direction.compass_dirs.items():
if d == degrees:
self._compass = name
break
return self._compass