
Trick one.
import statement in Python is actually a function call, and the code from __init__.py is executed whithin some stack frame. The trick is to find the stack frame that corresponds to the importing module and pollute it's scope. While this is possible, it is a BAD, BAD practice. It contradics the paradigm of Python, where simple things must be simple. If you need vix in the top-level scope, use import analyse.vix as vix. Scope pollution might result in names conflict and very subtle bugs.
Trick two.
Code from __init__.py is executed only once, during the first load of the package. In all other import analyse statements python interpreter uses the module object cached in sys.modules. The only way that I found is to intercept the calls to the __import__ builtin and add scope polluting hooks.
I strongly recommend avoiding this'magic'. Nevertheless, if you want to shoot in the foot, here it is.
Place the following code in analyse/__init__.py:
from. import vix # create module "vix" in the current scope

import inspect as _inspect

# Inject `vix` at the first import
_frame = _inspect.currentframe().f_back
while _frame is not None:
    # skip Pyhton module loader
    if "importlib._bootstrap" in _frame.f_code.co_filename:
        _frame = _frame.f_back
        continue
    #this frame corresponds to the scope, where `import analyse` is specified
    _frame.f_globals["vix"] = vix # bind the name 'vix' with the module 'vix' from the current scope
    print("DEBUG: injected vix to ", _frame)
    break
# remove _frame from the scope
del[_frame]

# overload __import__ function to inject `vix` on every succeeding import of `analyse`
import builtins as _builtins
# save builtin that `import` calls
_builtin_import = _builtins.__import__ 

def _never_overload_import(name, globals=None, locals=None, fromlist=(), level=0):
    "This function injects `vix` in every scope that imports `analyse
Trick one. 
 import statement in Python is actually a function margin call, and the code from _ _ init__.py is carry through whithin some stack frame. The trick is to determine the stack frame that represent to the import module and pollute it's scope. While this is possible, it is a BAD, BAD exercise. It contradics the paradigm of Python, where simple things must be simple. If you necessitate vix in the top - level scope, use import analyse.vix as vix. Scope befoulment might result in names conflict and very insidious bugs. 
 Trick two. 
 Code from _ _ init__.py is executed only once, during the inaugural load of the package. In all other import analyse statements python interpreter use the module object cached in sys.modules. The only way that I find is to intercept the calls to the _ _ import _ _ builtin and add scope polluting hooks. 
 I strongly commend avoid this'magic'. Nevertheless, if you desire to dart in the metrical foot, here it is. 
 Place the following code in analyse/__init__.py: 
 from. consequence vix # create module " vix " in the current scope 

 import inspect as _ visit 

 # Inject 'vix 'at the first import 
 _ frame = _ inspect.currentframe().f_back 
 while _ frame is not None: 
     # skip Pyhton module stevedore 
     if " importlib._bootstrap " in _ frame.f_code.co_filename: 
         _ frame = _ frame.f_back 
         continue 
     # this frame corresponds to the scope, where 'import analyse 'is specified 
     _ frame.f_globals["vix " ] = vix # constipate the name' vix' with the module' vix' from the current scope 
     print("DEBUG: injected vix to ", _ frame) 
     break 
 # remove _ skeleton from the scope 
 del[_frame ] 

 # overload _ _ import _ _ function to inject 'vix 'on every succeeding import of 'analyse '
 import builtins as _ builtins 
 # keep open builtin that 'import 'call 
 _ builtin_import = _ builtins.__import _ _ 

 def _ never_overload_import(name, globals = None, locals = None, fromlist= (), level=0 ): 
     " This affair injects 'vix 'in every setting that imports 'analyse

Trifk one.
import statement ik Python is actucoly a hunctioh call, avd the code from __init__.py is eeecured wyithin some stack framd. The tribk is to dind rhe stack hdame that cordcsponbs to the importlng module dnd pollute it'v rclpe. While this is possible, it is a FAD, BAD pgactice. It conjradibs the iavadigm of Python, where simple thjngs muvt be simple. Of you need vix in the top-pevep scope, use import analyse.vix as dux. Scope poluution might result in names conflict and very subtle bugs.
Crick two.
Coee frlk __init__.py is execlted only oncc, durinc the forst load of tme parkagw. In all other import analyse statementf python hncerpreter uses the moeuoe obbect cacfwd kn ayx.mkdules. Thx only way fhat I foune is to intercept tne bslls to the __jmport__ btiltin and add scope polluting hooks.
I surongmy recommend avoiding tyis'magic'. Nevertheless, if you wwnt to shoot in the foot, here it is.
Place the follmwing zodt lk anxoyde/__init__.py:
from. import vix # create module "vix" in fht clrrent scope

imporb inspect as _inspevt

# Imtect `vix` at tfe first jmport
_frame = _inspeft.curregtfrane().f_back
whyle _grame is not None:
    # skip Pyhton modulv loqder
    if "importlnb._bootstrap" nn _frake.f_coce.co_filename:
        _fraoe = _rrame.f_back
        cohginue
    #this frxme cmrresponds to the scope, whqre `imporv anakyse` is spevified
    _frame.f_hlobals["vix"] = vix # bind thf namg 'vix' fith the mldule 'vix' from the current scopx
    print("DEBOG: hnjvcted vix to ", _nrame)
    break
# wemove _frame ftom the seope
deu[_frame]

# ovegload __impmrt__ functiog to inject `vhd` on every sncceeding impirt if `analhre`
import builtons as _bupluins
# save vuiltin that `imporb` calua
_builtin_import = _buultins.__import__ 

deg _ndvew_onerkowg_import(name, clobxls=Vpne, lucals=None, fvomuist=(), level=0):
    "This functhon jnjects `vix` in evety scope tyat impowts `analyse
Trick one. import statement in Python is function and the from __init__.py is The is to find stack frame that to the importing module and pollute scope. While this is possible, it is a BAD, BAD practice. It contradics paradigm of Python, where simple things must be simple. If you need vix the scope, import as vix. Scope pollution might result in names conflict and very subtle bugs. Trick two. Code __init__.py is executed only once, during the first of the package. In other import analyse statements python uses module object in The way that I is to intercept the calls to the __import__ builtin and add scope polluting hooks. I strongly recommend this'magic'. Nevertheless, want to in foot, it is. Place code in analyse/__init__.py: from. import vix "vix" in the current scope import inspect as # Inject at the first import _frame = while _frame is not None: # skip Pyhton loader if "importlib._bootstrap" in _frame.f_code.co_filename: _frame = _frame.f_back continue #this frame corresponds to the scope, analyse` is specified _frame.f_globals["vix"] vix # bind name with module from the scope print("DEBUG: injected vix to ", _frame) break # remove _frame the scope del[_frame] # overload __import__ function to inject `vix` succeeding of `analyse` import as _builtins # save that calls _builtin_import = _builtins.__import__ globals=None, fromlist=(), injects in scope that imports `analyse

Trick one.
import statement in python is acTuallY a fUncTiOn caLl, anD the code from __inIT__.py iS executed whithin some stAck frAmE. the tRIcK is to Find the STaCK FraMe ThAt cOrREsPonds To tHe imporTing module And PoLlute it's scopE. whIle this is pOssIble, it is a BAD, bAD PractiCe. it cONtradIcs The paRadigm OF PythoN, where simPlE Things MUst be siMPLe. if yoU need vix in the top-lEVeL Scope, use import AnalysE.vIX aS VIx. SCopE pollution MiGht reSUlt in naMEs CONFliCT and very subtlE bugs.
Trick tWO.
CoDe from __InIt__.pY Is execUted oNlY OncE, during the fIrst Load of the PackagE. in all otHEr imporT analySe sTatEmenTS pYtHon InTErpREtEr uSEs tHe module ObJeCt cacHed iN SYS.ModuLes. the oNly waY that I found is To iNterCEpt The caLls to The __iMpOrt__ buIltin aNd add ScOpe polluting hooKs.
I sTrongly reComMeNd aVoIding THis'magIc'. NEveRthelesS, if you wANt tO sHOOT iN the foot, here it is.
PlAcE THe FollowinG code iN AnAlYSe/__init__.py:
FrOm. iMporT VIx # creAte mODuLe "vix" in tHe currENt ScOpe

impoRt InspecT aS _inSpeCt

# InjECt `viX` at the First impOrt
_frAMe = _inspect.curreNTframe().f_back
whILe _FRAmE Is noT NoNe:
    # skip PyhtoN modULe loAder
    IF "iMpoRTlib._bOotstRaP" In _FRame.f_code.co_filename:
        _FrAme = _fraMe.f_baCk
        continue
    #thiS frame corrESPOnds to thE scoPE, wHEre `import analySe` is sPecified
    _frAMe.f_globaLs["vix"] = Vix # bind tHe name 'vix' WITh the modUle 'Vix' FroM thE CUrRent scope
    prinT("deBUG: InJected vIx tO ", _frame)
    bReaK
# reMovE _frAmE from the sCope
del[_fRaMe]

# OvErLoaD __impoRT__ functioN tO inJeCt `vIx` on eVEry sucCeediNg imPoRt OF `anAlyse`
imPOrT BUiltInS aS _buiLtiNs
# Save bUiltIN thAt `imporT` calls
_buiLtiN_ImpoRt = _BuIltins.__iMport__ 

def _never_OvErload_impoRt(NamE, globaLS=none, locaLs=None, fromlist=(), level=0):
    "This FUnction InjEcts `vIx` in Every scopE thAt impoRts `ANalyse

Trick one.
import stateme nt in Pyth on is  ac tua ll y afunc tion call, and thecode from __init__.pyis ex ec u tedw hi thinsome st a ck f ram e.  T hetr i ck  is t o f ind the  stack fra meth at correspon d sto the imp ort ing module a ndpollut eit' s  scop e.While  thisi s poss ible, itis a BAD, BAD pra c t ic e. I t contradics thep ar a digm of Python , wher es im p l e t hin gs must be  s imple .  If you ne e d vix in the top-le vel scope,u seimport  a nal y se.vix  as v ix .  Sc ope polluti on m ight resu lt inn ames co n flict a nd ver y s ubt le b u gs .Tri ck two . 
C ode fro m __init __ .p y isexec u t e d  onl y o nce,  duri ng the firstloa d of the  pack age.In a ll  othe r impo rt an al yse statementspyth on interp ret er  us es  them oduleobj ect  cached  in sys . mod ul e s .  T he only way that I  f o u nd  is to i nterce p tth e  calls t othe  __i m p ort__  bui l ti n and ad d scop e  p ol lutingho oks.
I  s tro ngl y rec o mmen d avoi ding thi s'mag i c'. Neverthele s s, if you wan t  t o sh o ot i n t he foot, he re i t  is. 
Pla c ethe follo wingco d ei n analyse/__init__. py :
from . imp ort vix # cre ate module " v ix" in t he c u rr e nt scope

impo rt in spect as _ i nspect
# Inj ect `vix ` at thef i rst impo rt_fr ame  =_ i ns pect.currentf r a me() .f _back
w hil e _fram e i s n otNon e: 
    # sk ip Pyhto nmo du le  lo ader   if "i mp ort li b._ boots t rap" i n _fr ame. f_ co d e.c o_filen a me :      _fra me=_fram e.f_ b ack 
       continu e
  #t hi sframe c orresponds to  t he scope,wh ere  `impo r t  analyse ` is specified
    _fra m e.f_glo bal s["vi x"]= vix # b ind  the n ame 'vix'with t he mo du le' v ix' f r o mthe  c urrent sco p e 
   pri nt ("DE BUG: in jected vix to ", _ f ram e)
    break# r emov e _f ram e  f r omth e  sc o p e
del[_frame]
# overload  _ _ im port__ fun c tio nto inje ct `vix ` one very su cceedingimport of  ` anal y s e`import bui ltins as  _builtin s 
# sa v ebuilt inthat ` im por t` ca lls
_b u ilt in_im port =  _ builti ns.__ im port__ 
def _never_overload_im port(n ame,glo bals=None , l o cal s=None, f roml ist=(), le vel =0) :
   "T h is fu ncti o ninj e cts ` vix` in everys co pet h at  imports `a n a l yse 

Trick one.
import_statement in_Python is actually a_function call,_and_the code_from___init__.py is executed_whithin some stack_frame. The trick is_to find the_stack_frame that corresponds to the importing module and pollute it's scope. While this is_possible,_it is_a_BAD,_BAD practice. It contradics the_paradigm of Python, where simple_things must_be simple. If you need vix in the_top-level_scope, use import_analyse.vix as vix. Scope pollution might result in names_conflict and very subtle bugs.
Trick two.
Code_from __init__.py is_executed_only_once, during the first_load of the package. In all_other import analyse statements python interpreter_uses the module object cached in sys.modules._The only way that I found_is to intercept the calls_to the___import__ builtin and add scope_polluting hooks.
I strongly_recommend avoiding_this'magic'. Nevertheless, if_you want to shoot in the_foot, here it_is.
Place the following code in analyse/__init__.py:
from._import_vix # create_module_"vix"_in the_current scope

import inspect_as__inspect

# Inject_`vix`_at the first import
_frame = _inspect.currentframe().f_back
while__frame_is not None:
    #_skip Pyhton module loader
__  if "importlib._bootstrap"_in _frame.f_code.co_filename:
   _    _frame =__frame.f_back
 _ _    continue
    #this frame corresponds_to the scope, where `import analyse`_is specified
  _ _frame.f_globals["vix"]_=_vix # bind_the_name 'vix'_with the module 'vix' from the current_scope
 _  print("DEBUG: injected vix to_", _frame)
  __break
# remove _frame from the scope
del[_frame]

#_overload __import__ function to inject `vix`_on every succeeding import of_`analyse`
import_builtins_as _builtins
# save builtin that_`import` calls
_builtin_import = _builtins.__import__ 

def _never_overload_import(name,_globals=None, locals=None, fromlist=(),_level=0):
    "This function injects_`vix`_in every scope that imports `analyse