What is Python's Main Function Useful For?

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 74

  • @expansivegymnast1020
    @expansivegymnast1020 2 ปีที่แล้ว +29

    THANK YOU! This is one of those things people expect you to do but never explain why you have to do it. Like, I can understand that I have to have a main function but show me why and what happens when I don't.

  • @2ru2pacFan
    @2ru2pacFan 3 ปีที่แล้ว +57

    That is crazy as I was typing 'what is if __name__ == __main__' on the search bar, a notification popped up and it was this video. What a coincidence 😂 thanks dude

    • @dogwithwatergun1546
      @dogwithwatergun1546 3 ปีที่แล้ว

      Thats google cookies for you. Really useful but CAN be used for something else. I know it doesn't but it can.

    • @ninjacodertech
      @ninjacodertech 3 ปีที่แล้ว +1

      google is spying on you...

    • @dogwithwatergun1546
      @dogwithwatergun1546 3 ปีที่แล้ว

      @@ninjacodertech yes, but you're too boring for them to really look what you're doing.

    • @ninjacodertech
      @ninjacodertech 3 ปีที่แล้ว

      @@dogwithwatergun1546 what is wrong with you

    • @dogwithwatergun1546
      @dogwithwatergun1546 3 ปีที่แล้ว

      @@ninjacodertech google is spying on you... like yes its 2021, if you want privacy you should start by deleting youtube.

  • @Pogo_tC
    @Pogo_tC 2 ปีที่แล้ว +15

    I have done a lot of reading and practicing in Python never could understand the dunder thing was and now it finally clicked for me. Thanks, man!

  • @alexander.starbuck
    @alexander.starbuck ปีที่แล้ว +10

    BRILLIANT! After watching at least 10 other tutorials, I FINALLY undersand this concept. Great teaching skills and great style, keep it up ;)

  • @CliffR
    @CliffR 2 ปีที่แล้ว +5

    I’ve watched a few videos about this and by far you have the most clear understandable explanation

  • @holy5413
    @holy5413 2 ปีที่แล้ว +1

    my mind just exploded, I see lots of people using it but never had seen someone explaining it, thanks a lot!

  • @johnztech1651
    @johnztech1651 3 ปีที่แล้ว +1

    I like this man how he starts his videos and his explanaition. he looks fynny but serious. i expect more on python GUI

  • @tylerlee2612
    @tylerlee2612 8 หลายเดือนก่อน

    i understood this a lot more than what was discussed in the sc50 class! I need to find more simple, basic and vary beginner focused videos talking about how to structure these still though. Thanks for posting this though, it helped with a big part of the confusion on why we use these.

  • @Nircode
    @Nircode 3 หลายเดือนก่อน

    I'm from Harvard CS50, intro to python programming, this video has helped me a lot. Thanks

  • @danlekosh
    @danlekosh 3 ปีที่แล้ว +2

    YOU'RE TOO GREAT buddy, thanks for dissecting these python notions like that..

  • @andrewjenson_original
    @andrewjenson_original 11 หลายเดือนก่อน

    Thanks, I watched 5 other TH-cam videos on this topic and your video explained this topic the best.

  • @wko_
    @wko_ 3 ปีที่แล้ว +2

    Awesome!
    I had needed this in my project and I didn't know how to do it...
    Thanks again!

  • @user-hj2ed5pe6j
    @user-hj2ed5pe6j 2 ปีที่แล้ว +5

    How are you calling myvalue as global variables at 6:03. When you use if ___name___ == '__main__' then myvalue is definitely not a global variable. You have to use *global myvalue* before defining it to make it global.
    The error is not at all confusing. Its pretty clear.

    • @disrael2101
      @disrael2101 2 ปีที่แล้ว +3

      Ya i thought the same it's in if statement scope

    • @alejrandom6592
      @alejrandom6592 2 ปีที่แล้ว

      Only if inside a function, otherwise its implied to be global

  • @mohammedmusthafa959
    @mohammedmusthafa959 3 ปีที่แล้ว +1

    Finally understood why we use it!
    Thanks Man!

  • @chaks2432
    @chaks2432 3 ปีที่แล้ว +2

    Bruh, are you reading my mind or something? Just got lectured on the Python Subreddit yesterday for not using Main on a script I posted there, lmao

  • @thatguythatdoesstuff7448
    @thatguythatdoesstuff7448 4 หลายเดือนก่อน

    Something confusing to new learners is when you use .py names that are duplicative of non dynamic syntax.
    Calling the .py "main" when the if statement is not referring to the .py named main causes confusion.
    A new user will see that and attempt to change '__main__' to reference the .py they are trying to call the functions from.
    Otherwise, very good video.

  • @marcomoscoso7402
    @marcomoscoso7402 ปีที่แล้ว

    Best explanation of this in Yt

  • @darkuncle77
    @darkuncle77 2 ปีที่แล้ว

    You are the best teacher I have found. You are a genius. Thank you

  • @CloseStudios
    @CloseStudios 2 ปีที่แล้ว +1

    The best explaination I could find! Thanks a lot

  • @seanredmond9212
    @seanredmond9212 ปีที่แล้ว

    yeah I agree with other comment - saw other videos on this topic and I think your explanation was best. thanks.

  • @berkant8074
    @berkant8074 3 ปีที่แล้ว

    There is just one word to describe you guy : AWESOME.

  • @knowhowww
    @knowhowww ปีที่แล้ว

    Dude! WTH dude! thank ****! much love bro thanks

  • @rajkumar-zq4ov
    @rajkumar-zq4ov ปีที่แล้ว

    Very nice and detailed explanation...thank you so much

  • @DubZenStep
    @DubZenStep 9 หลายเดือนก่อน

    protect this man at all costs

  • @MrCipek1221
    @MrCipek1221 2 ปีที่แล้ว

    Thanks :) I just counted on that I could find a video with you explaining this :D

  • @malakarakesh3139
    @malakarakesh3139 8 หลายเดือนก่อน

    at 6:09, `myvalue` was still undefined even though it was globally defined. why was it so?

  • @bookweerd
    @bookweerd ปีที่แล้ว

    Thank you this was the best explanation for this topic!

  • @VeereshPatel15
    @VeereshPatel15 3 ปีที่แล้ว +2

    Love ❤ for ur efforts and ur content
    In future I am expecting
    videos on Frontend roles and Responsibilities like
    1. What actually do frontend developers do in realtime ( different tasks)
    2.. How manage 4+ experience in realtime
    3. . How to crack any frontend interviews with 4+ years of experience
    4.....Easy way to to crack any angular/reactjs interviews with 4+ experience/10lack package ------) ))
    5....Top 20 program's to cover entire angular/reactjs syllabus.----))
    6....Top 10 angular/reactjs concepts with examples

  • @Billcasiopost
    @Billcasiopost 11 หลายเดือนก่อน

    Exactly the answer I was after, thanks 👍👍

  • @0verflowSec
    @0verflowSec 3 ปีที่แล้ว +2

    Can you make video about Jython(Java + Python)

  • @xolaninqubezelo3091
    @xolaninqubezelo3091 ปีที่แล้ว

    Great video.

  • @patriciodiaz2377
    @patriciodiaz2377 ปีที่แล้ว

    Thanks so useful! And so easy to understand

  • @ivanoliveirapsd1337
    @ivanoliveirapsd1337 2 ปีที่แล้ว

    Great, help me to understand. Hugs from Brasil

  • @vasilebordei4668
    @vasilebordei4668 2 ปีที่แล้ว

    This video helped me a lot!! Thank you!

  • @Rnjeazy
    @Rnjeazy 8 หลายเดือนก่อน

    Thank you s so much!

  • @Menna23326
    @Menna23326 ปีที่แล้ว

    You are awesome!😃

  • @historyrogue5056
    @historyrogue5056 3 ปีที่แล้ว +3

    please do a Cython tutorial , and a question , is Cython more practical to use than CPython?

    • @IzUrBoiKK
      @IzUrBoiKK 3 ปีที่แล้ว

      Yes

    • @historyrogue5056
      @historyrogue5056 3 ปีที่แล้ว

      @@IzUrBoiKK Do you use it? can it actually make python code run in C code speed?

  • @emilioserrano7062
    @emilioserrano7062 ปีที่แล้ว

    beautiful, thanks a lot!!!

  • @vatsalgandhi93
    @vatsalgandhi93 2 ปีที่แล้ว

    great help man!! appreciate it !!

  • @benlong1062
    @benlong1062 2 ปีที่แล้ว

    This was really interesting. Thanks!

  • @jromeroevo
    @jromeroevo 2 ปีที่แล้ว +1

    Great tutorial. I do have a question. Don’t you need the keyword “global” to turn a variable into a global variable ?

    • @Anonymous-om5ql
      @Anonymous-om5ql 2 ปีที่แล้ว +2

      Yeah...even I was thinking of that

    • @user-yd2ee6sf8k
      @user-yd2ee6sf8k 2 ปีที่แล้ว

      no, it's just what we call the variable.

    • @sethadkins546
      @sethadkins546 2 ปีที่แล้ว +2

      Only if inside a function, otherwise its implied to be global

  • @Franx570
    @Franx570 3 ปีที่แล้ว

    Do the Nvim tutorial of the COC implementation or the new LSP of the Neovim 0.5 :(

  • @bazzkiller1331
    @bazzkiller1331 ปีที่แล้ว

    Shouldn't the if __name__ == "__main__" expression be only inside the "main" script? Not in "mylibrary"...

  • @tushermyth
    @tushermyth 2 ปีที่แล้ว

    Thanks for this! :)

  • @cylemmulo
    @cylemmulo 2 ปีที่แล้ว

    Thank you so much!

  • @SiTheMon777
    @SiTheMon777 ปีที่แล้ว

    Great explanation 🔥

  • @naro108
    @naro108 2 ปีที่แล้ว

    Great explanation

  • @oguzhantopaloglu9442
    @oguzhantopaloglu9442 3 ปีที่แล้ว +1

    can you do some tutorials of pillow?

  • @user-td4pf6rr2t
    @user-td4pf6rr2t หลายเดือนก่อน

    why do if __name__ == '__main__': not throw valueerror forexpecting else:

  • @alonelay
    @alonelay 3 ปีที่แล้ว

    so variable can't define as globally, but can define in local. And no error?

  • @redserpent
    @redserpent 2 ปีที่แล้ว

    excellent video. Tweeted.

  • @hicham_6544-_-
    @hicham_6544-_- 3 ปีที่แล้ว

    What theme are you using in pycharm ,bro 🤔

  • @LucPOLO
    @LucPOLO 9 หลายเดือนก่อน

    Bro, there are two possibilities, either you’re fucking genius teacher or others are terrible craps doing it. Whatever the answer is, as many others here i finally understood this concept after a few hours of unsuccessful researches.

  • @rashmikaabeyrathna1017
    @rashmikaabeyrathna1017 2 ปีที่แล้ว

    grate job

  • @ninjacodertech
    @ninjacodertech 3 ปีที่แล้ว

    ohhhhh this makes sense

  • @philtoa334
    @philtoa334 ปีที่แล้ว

    Thx_.

  • @churchofclaus
    @churchofclaus 2 ปีที่แล้ว

    🤯bro

  • @JarppaGuru
    @JarppaGuru 2 ปีที่แล้ว

    for all main part lol

  • @sohankulkarni6560
    @sohankulkarni6560 3 ปีที่แล้ว

    Is sumeet your Friend

  • @aditya_asundi
    @aditya_asundi 3 ปีที่แล้ว

    first