Keeping all Python imports in one file -


i have file , has lot of imports:

import x y import z , on ....  

is there way keep imports in file called 'allimports.py' , able as:

import allimports im 

then able use:

im.x im.z , on 

i want because file has 20 rows of imports, , it's going increase. why not practice?

when this:

file a.py:

import x 

it imports in x... including other imports. if x has defined @ top:

import y 

then can in a:

x.y 

therefore, if in a:

import x z 

you can do:

z.y 

the difficulty importing function @ point imported: adding degrees of indirection makes things such testing, , determining going on in file, harder. ides allow collapse import lists, means problem you're trying solve (not having see huge list of imports) more solved tool.

i note, too, 1 of important things code can readable. forcing use im. namespace in front of everything, occluding code doing, , preventing writing code elegant , easy read , understand.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -