Warning! I'm a noob to python and the following may not be the best way to solve the problem. It may even contain errors!
I wanted to create a python class that would contain most of the functions I needed to interface a Samsung VFD to a raspberry pi. The VFD connects to the pi using SPI. To make things a little cleaner, I wanted to initialize SPI from within my main class, called SPI_VFD in the code shown below. I also needed to call the functions spi.writebytes and spi.xfer2 (from the module spidev) from within my SPI_VFD class.
In initial testing, here's what worked for me:
import spidevclass thisspi:
spi = spidev.SpiDev()
class SPI_VFD:#instantiate spi connection
def __init__(self, callspi):
self.myspi = callspi
s = thisspi() # initialize SPI_VFD class, passing the spi instance
vfd = SPI_VFD(s)