Understanding if __name__ == “__main__” in Python | Python Main Function with Examples

Поділитися
Вставка
  • Опубліковано 12 гру 2024

КОМЕНТАРІ • 73

  • @heaven3279
    @heaven3279 2 роки тому +12

    Grateful that I managed to find this after several videos, managed to get the concept straight away after watching this. Thanks for the crystal explanation and the example.

  • @hammadahmed2339
    @hammadahmed2339 4 роки тому +21

    Best ever tutorial on name==main

  • @erikp9014
    @erikp9014 3 роки тому +7

    holy shit, I spent like an hour trying to figure out what this means, but every website went into so much details that I got so confused. it was simply that __name__ was = to __main__ when running it directly from the program it was created in at first or __name __ is = to that particular file name it was created in when its imported into another program. Thank you!

  • @jojomythe
    @jojomythe 2 роки тому +3

    I’ve been struggling to understand this concept with all other videos, and you gave me eureka!!🎉 thank you!

  • @kenn1ld676
    @kenn1ld676 3 роки тому +1

    Great explanation of if __name__ == "__main__":

  • @elhipster1
    @elhipster1 3 роки тому +2

    perfect concise explanation for me. Thanks so much. I was very confused before. Now I totally understand

  • @uditkumar7211
    @uditkumar7211 3 роки тому +1

    i was wandering here and there looking for precise explanation for this and you explained it very well sir thank you so much

  • @maulanakamal6188
    @maulanakamal6188 3 роки тому +1

    Very clear explanation

  • @egg5474
    @egg5474 4 роки тому +7

    This video: Me: imports 500 libraries into Hello World.py program

  • @hotshotgolfer3079
    @hotshotgolfer3079 2 роки тому

    Well Done Sir. I am not confused anymore. TY

  • @travelingsandy900
    @travelingsandy900 Рік тому

    Best explanation. Thank you very much

  • @theexposer9483
    @theexposer9483 Рік тому +1

    I am checking again from you, why anyone will in first place write a statement to run the same module which has been defined above. What purpose it would serve in the first place. If have to run the module I will import it and then run the function. First I unnecessarily put code inside my module file to run the code and then put if __name__=“__main__” to prevent it from running. One reason for putting such code is to make .py file more versatile, it can be run directly without importing hence use of less memory and can be imported and run as and when required inside another application. Please enlighten us. Thanks in advance.

  • @keralatalks7435
    @keralatalks7435 2 роки тому

    Very clear, didnt get the proper idea, while watching other videos in youtube

  • @soliver111
    @soliver111 7 місяців тому

    Very clear explanation
    Thank you

  • @acronproject
    @acronproject 2 роки тому

    thanks for this
    💯💯💯💯💯💯💯💯💯💯💯💯💯💯💯

  • @dontrunjustfaceit4045
    @dontrunjustfaceit4045 Рік тому

    Good explanation. Thank you.

  • @Anteater23
    @Anteater23 2 роки тому

    Thanks for this good video.

  • @selbimammetgulyyeva2349
    @selbimammetgulyyeva2349 3 роки тому +1

    Very clear explanation. Thank you!

  • @Twoman-bodyweight-journey
    @Twoman-bodyweight-journey 3 роки тому +1

    tnx for this turtrial ,finally i understood this

  • @omarfthoaib8749
    @omarfthoaib8749 3 роки тому +1

    Now it makes sense! Thanks bro...

  • @cannedpineapple438
    @cannedpineapple438 3 роки тому +1

    Best explanation

  • @vijay.e4228
    @vijay.e4228 3 роки тому +1

    nice explaintion

  • @DominiqueOlaniyi
    @DominiqueOlaniyi Рік тому

    Amazing explanation

  • @FelLoss0
    @FelLoss0 Рік тому

    Amazing and concise explanation, sir. Thank you very much!

  • @dayanarodriguezponce5512
    @dayanarodriguezponce5512 3 роки тому +1

    thanks for the video you help me a lot

  • @riverasanchez
    @riverasanchez 3 роки тому +1

    Very good explanation and example! Thank you!

  • @pgokulsreenivas
    @pgokulsreenivas 10 днів тому

    best explanation ever

  • @wudassiewalle46
    @wudassiewalle46 2 роки тому +3

    I have watched a couple of videos on this topic and they didn't do any good except more confusion. But this explanation so clear without going around the bush. Keep us the good work. 👏

  • @26_jyotigoel6
    @26_jyotigoel6 6 місяців тому

    best explanation😃

  • @Sam-jg5zv
    @Sam-jg5zv 4 роки тому +3

    Great video and clear explanation. Keep up the good work!

  • @snehan3341
    @snehan3341 3 роки тому +1

    thank you so much sir!!!!!!!!!!

  • @sahilapte7735
    @sahilapte7735 4 роки тому +1

    nice explanation

  • @BrGr385
    @BrGr385 Рік тому

    great explanation thanks a lot!

  • @brielleshepard
    @brielleshepard 11 місяців тому

    Great video! Really broke it down. Thumbs up! :)

  • @Online-rr8pk
    @Online-rr8pk Рік тому

    Top video, so easily understandable ! Thanks a lot! 👍👍👍

  • @ntnsve
    @ntnsve 8 місяців тому

    Perfect example!

  • @dimitrismwrakis6910
    @dimitrismwrakis6910 3 роки тому +1

    Excellent explanation!

  • @lotusgraceinwhite
    @lotusgraceinwhite 7 днів тому

    After watching 5 to 6 vdos finally understood here

  • @nitinmaurya6835
    @nitinmaurya6835 3 роки тому +1

    U made it so clear that I subscribed you :D

  • @NavrozbekQosimov
    @NavrozbekQosimov 4 роки тому +1

    🌟Good !👍👆👏😎🌟

  • @vamsiakula9860
    @vamsiakula9860 3 роки тому +1

    3 blogs, 2 videos - No use
    This 1 video - Enough

  • @jason_huang03
    @jason_huang03 2 роки тому

    good job! quite explicit

  • @sushank7471
    @sushank7471 2 роки тому

    well explained

  • @123arskas
    @123arskas 2 роки тому

    Awesome explanation.

  • @danishuddin9752
    @danishuddin9752 2 роки тому

    Beautiful explanation thanq

  • @hirucci8986
    @hirucci8986 4 роки тому +2

    Thanks a lot for making many useful video and playlist tutorial like this.
    Really helpful for CS student like me.
    :)

  • @nepalimusician6445
    @nepalimusician6445 3 роки тому +3

    Watched 3 videos before this but didn't get it. Thanks for clarifying in such as a simple way.

  • @charithjeewantha
    @charithjeewantha 3 роки тому +1

    Thank you!

  • @billseaman3103
    @billseaman3103 2 роки тому

    Very helpful, love you ):D

  • @harivarsanpappu5142
    @harivarsanpappu5142 Рік тому

    Great

  • @malakarakesh3139
    @malakarakesh3139 11 місяців тому

    does the spawned process also get the same __main__ value for __name__? how does this work with multiprocessing?

  • @sujalsharma5181
    @sujalsharma5181 2 роки тому

    awesome explanation 👌cant be better 👍

  • @reiyamamoto6507
    @reiyamamoto6507 4 роки тому +3

    What IDE do you use?

  • @x-tremeprogrammer
    @x-tremeprogrammer 4 роки тому +1

    Thank man

  • @siddanathampadmaraju4477
    @siddanathampadmaraju4477 Рік тому

    thank you...

  • @umeshb8210
    @umeshb8210 4 роки тому +2

    Can we use "from mymath import add" ?

    • @seanli75
      @seanli75 3 роки тому

      I think we can

  • @yolokaikai4071
    @yolokaikai4071 4 роки тому +4

    My first year lecturer spoke with that same exact ascent 😂

  • @arifaufdemweg9064
    @arifaufdemweg9064 2 роки тому

    best one

  • @zndxclips4810
    @zndxclips4810 Рік тому

    thx man

  • @USMColdies
    @USMColdies 3 роки тому +1

    I understand how it's used but not why there is a use for it. The return statement in a function is syntactically used to exit a function, why would there be additional statements after the return statement? Seems like bad programming, not sure how, when or why there is a use case for this...anybody knows?

  • @DeepakVerma-gy3zu
    @DeepakVerma-gy3zu 3 роки тому +1

    How result invalid syntax

  • @aditya__exe
    @aditya__exe 3 роки тому +1

    test.py the universal name😂😂😂😂

  • @cagataytekin6372
    @cagataytekin6372 Рік тому

    buyuksun hoca

  • @aleXelaMec
    @aleXelaMec 2 роки тому

    great explanation, but too much underscores!!! )) its dunder methods

  • @Dr_piFrog
    @Dr_piFrog 4 місяці тому

    good explanation