From 1e324c0a3cdabf62984ffc825b5331dbef16bdef Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 19 Mar 2012 09:04:42 -0400 Subject: [PATCH] Add .channels() method to Subdevice class. --- pycomedi/subdevice.pyx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pycomedi/subdevice.pyx b/pycomedi/subdevice.pyx index a38c434..9042e7a 100644 --- a/pycomedi/subdevice.pyx +++ b/pycomedi/subdevice.pyx @@ -156,6 +156,15 @@ cdef class Subdevice (object): insn.subdev = self.index return insn + def channels(self, **kwargs): + "Iterate through all available channels." + ret = [] + for i in range(self.get_n_channels()): + #yield self.channel(i, **kwargs) + # Generators are not supported in Cython 0.14.1 + ret.append(self.channel(i, **kwargs)) + return ret + def channel(self, index, factory=_Channel, **kwargs): "`Channel` instance for the `index`\ed channel." return factory(subdevice=self, index=index, **kwargs) -- 2.26.2