On Thu, Sep 4, 2008 at 6:00 PM, Roy Khristopher Bayot <[EMAIL PROTECTED]>wrote:


> Correct me if I am wrong but each "import os" statement only exists in each
> method.  Is there a way to only import the os module once and use it in each
> method?
>

Move it to the top of the file, outside of the class definition:

import os
class CamHandle(object):
    def __init__(self):
        w = os.system('gphoto2 --auto-detect > CamHandleLog.txt')
        test = os.system('gphoto2 --capture-image >> CamHandleLog.txt')

    def captureImage(self):
        x = os.system('gphoto2 --capture-image >> CamHandleLog.txt')

    def getAllImages(self):
        y = os.system('gphoto2 --get-all-files >> CamHandleLog.txt')

    def deleteAllImages(self):
        z = os.system('gphoto2 -DR >> CamHandleLog.txt')

I haven't tested your code, but this should work just fine.

-- 
www.fsrtechnologies.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to