Skip to content

Commit

Permalink
Add spaces to comma separated composite device elements in repr and o…
Browse files Browse the repository at this point in the history
…nly show unnamed when there are some
  • Loading branch information
bennuttall committed Sep 20, 2019
1 parent 8a9a325 commit d0d1cb8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gpiozero/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,17 @@ def __setattr__(self, name, value):
def __repr__(self):
try:
self._check_open()
return "<gpiozero.%s object containing %d devices: %s and %d unnamed>" % (
self.__class__.__name__,
len(self), ','.join(self._order),
len(self) - len(self._named)
)
if len(self) - len(self._named) > 0:
return "<gpiozero.%s object containing %d devices: %s and %d unnamed>" % (
self.__class__.__name__,
len(self), ', '.join(self._order),
len(self) - len(self._named)
)
else:
return "<gpiozero.%s object containing %d devices: %s>" % (
self.__class__.__name__,
len(self), ', '.join(self._order)
)
except DeviceClosed:
return "<gpiozero.%s object closed>" % (self.__class__.__name__)

Expand Down

0 comments on commit d0d1cb8

Please sign in to comment.