S
S
Sergey Orlov2020-11-20 12:26:52
Python
Sergey Orlov, 2020-11-20 12:26:52

How to import certain strings in Python?

There are two files, main and site.
It is necessary to import a certain part of the code from main to site, but from main import * does not work, because there is a line from site import * in the main file, because of this, the code stops.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-11-20
@GaNNN

You misunderstand what an import is in python.
The code in general and program lines in particular are never imported anywhere. All modules are executed in their entirety at the time of their first import or, in the case of the main program, at the time of its launch.
In addition to running code during the first mention in an import statement, this statement allows you to get some (specified) or all (public) names from the imported module (or package) into the global namespace of the module.
Sounds like you should read some simple book to learn python. What I told you here is too little to fully program in the language.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question