I just finished a small all-python3 gpio module for use with Linux gpiolib
. I've toyed with two different ways of naming and importing things in the client:
1
gpio.py
class GPIOInput(object):
...
class GPIOEvent(object):
...
class GPIOOutput(object):
...
client.py
from gpio import GPIOEvent, GPIOOutput, GPIOInput
irq = GPIOEvent(1, 14)
2
gpio.py
class Input(object):
...
class Event(object):
...
class Output(object):
...
client.py
import gpio
irq = gpio.Event(1, 14)
Question: Is there a good/concrete reason to prefer one over the other? Or is it just preference?
There isn't (for me) really a happy hybrid. I like the short names when scoped inside of the module, but if used outside of the module, really need the module name to qualify what they are. But importing gpio, and then referring to gpio.GPIOOutput seems redundant.