concise code (beginner)

bambam david at asdf.asdf
Thu Sep 6 22:03:26 EDT 2007


Hi Steven.

Looking at your code, why are you naming the value
__all__? It looks like a built-in variable?

Unless there is an automatic way to correctly get the
function list, I will probably be better off giving the lines
sequence numbers, and generating the function list from
that.

Steve.

"Steven D'Aprano" <steve at REMOVE-THIS-cybersource.com.au> wrote in message 
news:13dvvgk96amhhec at corp.supernews.com...
> On Thu, 06 Sep 2007 15:44:57 +1000,
> "bambam" <david at asdf.asdf> wrote in message
> news:13dsvqrqivtf092 at corp.supernews.com...

>
> Try something like this: define a module holding the device functions.
>
> # module script
>
> __all__ = [a0010, a002, a0030, a0040, a0050]
>
...
# module test1
 import script
class Test1(pl_test.Pl_test)
"""ADC calibration and Battery Voltage calibration"""
    def run(self,devlist):
         for line in script.__all__:
             for self.dev in devlist
                 if self.dev.active and not self.dev.failed
                 try
                     line(self)
                 except Exception,e:
                     print e
                     self.dev.active=False

         print "The following devices passed:"
         for dev in devlist
             if dev.active and not dev.failed
                 print dev

         print "The following devices need to be re-tested"
         for dev in devlist
             if not dev.active
                 print dev

         print "The remaining devices failed"
         for dev in delist
             if dev.active and dev.failed
                 print dev

> -- 
> Steven.
> 





More information about the Python-list mailing list