Похожие чаты

Is main a file ?

13 ответов

14 просмотров

Don't get you??

If you name your file that way, then yes it is a file. If you don't name a file like that, then no, it isn't a file.

You mean in the context of if __name__ == "__main__"? If so, __name__ is a variable that all python programs have, if you run your python file directly from the interpreter (e.g. if you do something like $ python my_script.py) then the value of __name__ for my_script will be "__main__", but ONLY if you execute that file directly like $ python my_script.py.

A- Автор вопроса
Link 🪈
You mean in the context of if __name__ == "__main_...

But when we import smth isn't it being runned by python?

A- Автор вопроса
A
I mean the code which we import

Then, __name__ is assigned the fully qualified name of the module it is defined in, most cases the file name of the module (the file with .py extension) that is imported

A- Автор вопроса
Link 🪈
Then, __name__ is assigned the fully qualified nam...

I knew it , but when we run something that is imported then it also runs directly from interpreter ,does it?

A
I knew it , but when we run something that is impo...

You can only run or import a python module, not both at the same time. If you were to have: import module1 module1.func() inside module2.py and then run module2.py, you'd have run module2 and imported module1. You can run module1 directly, but it wouldn't be imported (you can't import a module inside itself)

A- Автор вопроса
Link 🪈
You mean in the context of if __name__ == "__main_...

You sad if a module runs directly from interpreter then it is name is main So when i import module 1 to module 2 ,then module 1runs directly from interpreter but it is name is not main

A
You sad if a module runs directly from interpreter...

When you import module 1 into module 2 and you run module 2, module 1 is not run directly, but module 2 is. In this case module 2 __name__ is __main__, but module 1 __name__ is not.

A- Автор вопроса

U confused me a bit by saying "runs directly from interpreter"

A- Автор вопроса
Link 🪈
When you import module 1 into module 2 and you run...

I thought when we import it copies the code from module 1 to module2

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта