A
A
Andrew2018-09-02 20:23:12
Python
Andrew, 2018-09-02 20:23:12

Why doesn't import work in Python?

The question is banal, but I stalled at this point.
There is a main file, and there is a module that contains one function. They are in the same folder. In the main file there is a function call from the module.
It works if from test_function import abc, but it doesn't work if import test_function (I want all subsequent code from the module to be automatically imported into the main file in the future). Am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
B
barker, 2018-09-03
@AndrewRusinas

Am I doing something wrong?

Yes

G
GavriKos, 2018-09-02
@GavriKos

How do you call?
If I remember correctly - in the second case, you need to call through the module - test_function.abc()

W
West14, 2018-09-02
@West14

from test_function import *

I
igorzakhar, 2018-09-02
@igorzakhar

import test_function

test_function.abc()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question