I cannot make two modules of the same package "recognize"

Asked

Viewed 42 times

-2

Good evening, I’m learning more about importing and creating packages. But I can’t get two modules to "communicate", follow the link:

https://github.com/Gramosa/Importacao_teste

If you look at the two functions.py and point.py modules in the plano_cartesian folder, you can see that in each file there is a need for the other (because some functions and methods in the classes return or use things from the other file). For example in the functions.py file has the Function class that has a get_point() method, this method returns a Point object, but this Point class is in the point.pyfile. Dai to try to interconnect these two modules, I imported both in the file init.py that is inside the folder plano_cartesiano. Then outside the folder is a test.py file that when it is run imports the plano_cartesian package (as can be seen inside the file). I will copy here the text from the test.py file

from plano_cartesiano import *

a = Function(1, 2): #f(x) = x + 2
ponto1 = a.get_point(2)#f(x) = 2 + 2 = 4
#vai dar erro dizendo que Point não esta definido

Using the same example to sum up the doubt, it would be necessary that I import everything from functions.py into point.py and vice versa? or am I doing everything wrong? Thanks in advance :)

  • 1

    The code must be contained in the question and not in a link. If one day you decide to delete the repository you would invalidate both the questions and the answers. Then place a [MCVE] reflecting the proposed problem in the question.

  • but the code is divided into several different files, I do not know how to post here in an organized way

  • Filing cabinet mai.py: ...... Filing cabinet con.py: ......

1 answer

-2

I may be wrong, but I believe that if you import the Point class at the beginning of the functions.py code, it should work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.