[email protected] writes:
> ADC, DAC components. As I said, I would like to derive the
> corresponding classes from one common class, let's say I2CDevice, so
> that they can share the same bus connection (I don't want to do a
> import smbus, ..., self.bus = smbus.SMBus(1) all the time).
I don't really understand the question but it sounds like you might
want a class variable:
import smbus
class I2CDevice
bus = smbus.SMBus(1)
def __init__ (self): ...
This puts the "bus" object into the I2CDevice class itself. It is
created when the I2CDevice class is defined. Methods wanting to access
it can then say
do_something_with(I2CDevice.bus)
is that what you wanted?
--
https://mail.python.org/mailman/listinfo/python-list