Importing modules and hierarchies - Python

1

Personally I have the following question.

I am studying importing modules and grabbed the following problem, my directory is configured as follows:

Doubt 1 - > I want to import the operation modules to print and vice versa

Doubt 2 - > Import outro_módulo.py to imprimir.py or to one of the operation modules.

I've already used this procedure:

import imp  
arquivo, caminho, descrição = imp.find_module('módulo', ['/caminho/do/módulo/'])
nome_pro_módulo = imp.load_module('módulo', arquivo, caminho, descrição)  

(worked but if changing machines can conflict with path)

I've used this too:

import ..operacao import soma

But the following error occurs: Parent module '' not loaded, cannot perform relative import

Would anyone know where I'm going wrong?

    
asked by anonymous 21.01.2017 / 11:17

1 answer

0

Within the module imprimir , just import as follows:

from operacao import soma
    
29.01.2017 / 19:01