python3: Fix PEP8 and avoid crash when listing

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>