Advanced Exception Handling in Python

Sdílet
Vložit
  • čas přidán 31. 05. 2024
  • In this video, we learn how to professionally handle exceptions in Python. This goes beyond just basic try and except blocks.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine.com/books/
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🎙 Discord: / discord
    🎵 Outro Music From: www.bensound.com/
    Timestamps:
    (0:00) Intro
    (0:15) Basic Exception Handling
    (2:06) Pass Statement
    (3:15) Explicit Exception Handling
    (5:13) Multiple Exception Handling
    (5:40) General Exception Logging
    (7:00) Multiple Exceptions in Same Block
    (9:07) Re-Raise Exceptions
    (10:25) Finally Statement
    (11:00) Else Statement
    (11:33) Outro
  • Věda a technologie

Komentáře • 45

  • @dagpag1
    @dagpag1 Před rokem +22

    This should not be labeled as advanced exception handling because it is missing topics like exxeption chaining, traceback, exception hook, signal handling etc

  • @NiceChange
    @NiceChange Před rokem +5

    This is a great video for understanding the try/except usage in Python. Creating a good knowledge of the fundamentals is essential. Nice work! Thank you.

  • @leftblank5315
    @leftblank5315 Před rokem +10

    If you re-raise an exception, you should generally do it so: "raise from e". Internally, it sets a few flags and references the original exception.

  • @Raiden_Amani
    @Raiden_Amani Před 9 měsíci

    Thank you so much. You are honestly a very useful and coherent source for beginners, professionals, and all in-between 👍🏾.

  • @no_______one
    @no_______one Před rokem +2

    I am truly amazed how much knowledge you have and how well you transmit it.
    Every video is truly appreciated, thanks a lot for saving me and thank you in advance for all people that you are going to help in the future 📈

  • @rhambosnax864
    @rhambosnax864 Před rokem

    Thank you very much. I was really looking for this and you just uploaded it

  • @aswinmathew2472
    @aswinmathew2472 Před rokem

    I want to ask a doubt about the neuralintents package
    Can I put a default command like for example if the message I gave dosent match any of the patterns I have listed on the intents file do something or say something as default?

  • @the_huge_knight
    @the_huge_knight Před rokem +2

    Also if you create a class in Python, in its methods you should (catch and) raise some exceptions (if something goes wrong) and catch them in the main function of your program.

  • @asapnino3625
    @asapnino3625 Před měsícem

    thanks for this, was struggling with this but i "finally" do understand it.

  • @Schrom
    @Schrom Před rokem

    First of all, thanks for this video :)
    Now my comment :D
    I think its a good practice to avoid these try catching if possible. For example if you already know a division by zero could happen, you can check it and if it would be the case you can throw an exception by yourself.

  • @beliakovdev8059
    @beliakovdev8059 Před rokem

    Glad to watch concise and at the same time such an informative video.💥

  • @harrycrab8725
    @harrycrab8725 Před 11 měsíci +4

    Great video. I’m interested in more advanced topics like implementing traceback, if/when to subclass Exception, and custom errors.

  • @Alexander-ms2ct
    @Alexander-ms2ct Před rokem

    Keep doing what you are doing. You aren’t popular. But people care and watch. You are doing good

  • @paulthomas1052
    @paulthomas1052 Před rokem

    Thanks - very useful !

  • @Mike-vj8do
    @Mike-vj8do Před 11 měsíci

    this guy is great, thank you for the video

  • @efox29
    @efox29 Před rokem

    Every video is a banger.

  • @redspade2303
    @redspade2303 Před 21 dnem

    Trying out Python, I learned you can execute functions right from the console. Is there a way to catch exceptions from functions written and executed directly in the console (not the source code) ?

  • @kashifrana6798
    @kashifrana6798 Před 10 dny

    What continue does in exception handling? Pass means ignore but what continue does?

  • @iankamandew9777
    @iankamandew9777 Před 5 měsíci

    Thanks alot man!

  • @vihanvalizade1088
    @vihanvalizade1088 Před 11 měsíci

    that was perfect
    thanks

  • @EbenHodzi
    @EbenHodzi Před 7 měsíci

    Good work bro

  • @amurara3012
    @amurara3012 Před rokem

    tks man, u are great

  • @kamelboudaoud-qh7od
    @kamelboudaoud-qh7od Před rokem

    thank you for all this and i want you make a video about qiskit

  • @seanshimon
    @seanshimon Před 2 měsíci

    When did Michael Mando start coding ? 🤣
    Now really, thank you for great lesson.

  • @imrealgigachad
    @imrealgigachad Před rokem +8

    Can you make a video about pynecone ?

    • @AJXD2
      @AJXD2 Před rokem

      Dad is that you

  • @Brennmeister
    @Brennmeister Před rokem +2

    Is it possible to have something like a watchdog? That checks every 5 sek if a program is still running.
    And is it possible to restart a thread if an error raised an failure.

    • @SP-db6sh
      @SP-db6sh Před rokem

      What an practical implementation of this video instantly advised by you ! Amazing.... What's your actual usecase?
      In that case need an decorator function which will restart this child function on awkward return value from it...

    • @Brennmeister
      @Brennmeister Před rokem

      @@SP-db6sh oh ok. I will try to solve the problem with
      The watchdog is just something like a ping. Every second try to reach all clients. If there is noch answer stop all processes

  • @mecheng84
    @mecheng84 Před 11 měsíci

    whats the difference between else and finally block ? they kind of do the same thing.

    • @Harry830
      @Harry830 Před 6 měsíci +1

      else gets executed when there is no error whereas finally gets executed no matter error or not

  • @struggle375
    @struggle375 Před 4 měsíci

    Thanks

  • @rfatefehelvacoglu335
    @rfatefehelvacoglu335 Před 10 měsíci

    i watched this from many channels none of them included what finally does

  • @knolljo
    @knolljo Před 6 měsíci

    This is rather basic exception handling

  • @martinstrnad3243
    @martinstrnad3243 Před rokem

    I think it's wrong for the exception handling video to show printing errors to stdout instead of stderr.

  • @YoungTalent777
    @YoungTalent777 Před 8 měsíci

    I learnt something

  • @user-mu3fe7ip1i
    @user-mu3fe7ip1i Před rokem

    😍😍😍

  • @philtoa334
    @philtoa334 Před rokem

    Thx_.

  • @karen-7057
    @karen-7057 Před měsícem

    i wouldnt call this "Advanced". was expecting more.

  • @superkorki98
    @superkorki98 Před rokem +1

    is this what you call advanced? 🤣

  • @cappy2112
    @cappy2112 Před měsícem

    this is basic exception handling, nothing advanced at all

  • @eseajidekpu7536
    @eseajidekpu7536 Před 11 měsíci

    HE NEEDS TO LEARN HOW TO EXPLAIN MORE THOROUGHLY

  • @kutilkol
    @kutilkol Před rokem

    Whack