[Tutor] do i have to import modules at the start of a file?

Michael Langford mlangford.cs03 at gtalumni.org
Thu Sep 27 15:27:07 CEST 2007


In your particular situation, I've often used the "One Library, two
executable" pattern.

Put all the common functionality into one python module. Have one
python file who's main brings up a GUI and one who brings up the admin
cli interface, both of which that import the main library that does
all the common things.

            --Michael

On 9/27/07, shawn bright <nephish at gmail.com> wrote:
> It's the second one, not all the modules will be available on the portable
> version. But the threads that require those modules will not be necessary on
> the portable version. I want to be able to go to any linux computer with GTK
> and mysqldb installed and check out my stuff from svn and run the admin part
> of the program. But the main computer at work that takes data in will need
> the modules to run the threads.
>
> thanks for your help on this
>
> shawn
>
>
> On 9/26/07, Kent Johnson <kent37 at tds.net> wrote:
> > shawn bright wrote:
> > > lo there all,
> > >
> > > i have a gui program that imports a few modules that i don't need if i
> > > am using the program remotely.
> > > The program has an admin interface and thread interface, only the admin
> > > interface is needed when
> > > i am using the program from a remote computer.
> > >
> > > all of my modules are imported at the start of the file, and not
> > > initiated till a certain button is clicked on the GUI, could i put those
> > > import statements in the button click event?
> >
> > Yes but why do you want to? The reasons I know for doing this:
> > - the import takes a long time or a lot of memory and you don't want to
> > incur the cost unless you need it
> > - the imported module may not be available always and you want the rest
> > of the importing module still to be usable
> >
> > Kent
> >
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.TierOneDesign.com/
Entertaining: http://www.ThisIsYourCruiseDirectorSpeaking.com


More information about the Tutor mailing list