![]() |
Import a Module
I usually import all the needed modules in the beginning of my program. I keep seeing code that imports modules within a function, wouldn't that be bad? I assume that the module will be imported every time the function is called.
|
I've done it before without any problems, though I would avoid importing the randomizer in a function. The module would be loaded at the beginning of the function (or where ever) and dropped at the end, so it's I think it's okey. I don't recommend doing it that way because it hurts performance if that function is used often. I would do it in a function that's not used often, otherwise I would import it at the beginning of the code like usual.
|
Quote:
:
|
Quote:
|
It will only get searched once you import the module at file scope. It will be searched every time you run the function if you import inside the function.
|
Quote:
|
| All times are GMT -5. The time now is 11:18 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC