At 2:47 onward, I began to actually grasp what this concept might mean. All other videos I watched did not help until I found this one. I owe you the career I make later in life!!
# *********************************** # if __name__ == '__main__' # *********************************** # y tho? # 1. Module can be run as a standalone program # 2. Module can be imported and used by other modules # Python interpreter sets "special variables", one of which is __name__ # Python will assign the __name__ variable a value of '__main__' if it's # the initial module being run def main(): print("Hello!") if __name__ == '__main__': main() # ***********************************
what if the name of the module is __main__? then __main__.__name__ would be __main__ even if it is imported isn't it ? btw would the name __main__ be accepted as a valid name?
Thank you, I really like your methods in presenting a concept. I do have a comment on this video: But even without this code: if name == main, import (file_name) will be enough to run every code in the imported file. What I mean is that if name main is not essential to access codes from another file. It is also not essential to run a program. I would like to see a program that absolutely cannot work without if name main command.
Sorry cause this is unrelated to the content of this video. But how do you trim off all the zeros in a printf statement. So for example I have 43.33 as a double and listed as %f.2 but it shows as 43.3300000 in the command prompt. How do I fix it. Thanks in advance
At 2:47 onward, I began to actually grasp what this concept might mean. All other videos I watched did not help until I found this one. I owe you the career I make later in life!!
same
# ***********************************
# if __name__ == '__main__'
# ***********************************
# y tho?
# 1. Module can be run as a standalone program
# 2. Module can be imported and used by other modules
# Python interpreter sets "special variables", one of which is __name__
# Python will assign the __name__ variable a value of '__main__' if it's
# the initial module being run
def main():
print("Hello!")
if __name__ == '__main__':
main()
# ***********************************
watched so many other videos but still didn't get a clarity on what that code meant. But you explained it very well. Thank you.
You explained this so much clearer than the other videos I watched. Thank you!
Dude! Thank you! I was so confused in my textbook. Always come to your channel to understand.
Thank you. I never ever was able to understand this topic so clearly till now.
I've missed watching your videos. I am so happy that I have a reason to again
So, I've just realized that it is needed to be used if you wanna use some function or maybe a variable from a file and don't run it entirely
Organic Chem Tutor of Python
i know that i know nothing :) but in few seconds i will know less nothing and eventaully i will know something. Thx once again !!
So good !
Dude, Bro Code is the only Human coder in the world that can explain something complex and simplify it.
Thanks a lot for this video!
Wow!
thx 4 vid bro !
bro this video is like, so underrated
double like
thank you bro
Thank you!
thanks chad This helped a lot
what if the name of the module is __main__?
then __main__.__name__ would be __main__ even if it is imported isn't it ?
btw would the name __main__ be accepted as a valid name?
Thank you, I really like your methods in presenting a concept.
I do have a comment on this video:
But even without this code: if name == main, import (file_name) will be enough to run every code in the imported file.
What I mean is that if name main is not essential to access codes from another file. It is also not essential to run a program.
I would like to see a program that absolutely cannot work without if name main command.
Thanks man!
hello
Thx Bro!!!
Hi
ty bro
so basically, its just used during importing modules right?
yep
ty man
You make it easy to understand budda.
I'm understanding more now xD
Mine doesn't work the same 7/22/2022. I wonder if the pycharm software version was updated to work differently.
So basically its only __main__ within of itself
Sorry cause this is unrelated to the content of this video. But how do you trim off all the zeros in a printf statement. So for example I have 43.33 as a double and listed as %f.2 but it shows as 43.3300000 in the command prompt. How do I fix it. Thanks in advance
Here you go
too late but you can use the round function like that round(number, 2)
the second argument is the number of digits after the decimal point
Yo, what IDE is that? It looks really similar to android studio
Sublime I think
PyCharm
@The Codfather YOOOOOOOOOOOOOOOOO 😀👍😀😀
@@thecodfather7109 bruhhhh
Wtf?? entendi foi nada kkk
boobookittyfaq