[Tutor] how do you make this a better code?

Roy Khristopher Bayot roybayot at gmail.com
Sat Sep 6 16:09:57 CEST 2008


Hi. I tried it. It worked. Thank you.

On Fri, Sep 5, 2008 at 9:42 AM, Kent Johnson <kent37 at tds.net> wrote:

> On Thu, Sep 4, 2008 at 9:00 PM, Roy Khristopher Bayot
> <roybayot at gmail.com> wrote:
>
> > class CamHandle(object):
> >     def __init__(self):
> >         import os
> >         w = os.system('gphoto2 --auto-detect > CamHandleLog.txt')
> >         test = os.system('gphoto2 --capture-image >> CamHandleLog.txt')
> >
> >     def captureImage(self):
> >         import os
> >         x = os.system('gphoto2 --capture-image >> CamHandleLog.txt')
> >
> > Now when I import the file to the interpreter and instantiate the class,
> it
> > works. Each function works. I havent done any error handling or exception
> > handling yet but it works for now. However, I am bothered with the import
> > statements in each function.
>
> The usual method is to put the import statement at the beginning of
> the module. Then the imported module has global (module) scope rather
> than function scope.
>
> Kent
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080906/869121a3/attachment.htm>


More information about the Tutor mailing list