python debugger crash course: pdb / breakpoint (beginner - intermediate) anthony explains

Поділитися
Вставка
  • Опубліковано 8 січ 2025

КОМЕНТАРІ • 37

  • @TheMarksdaspark
    @TheMarksdaspark 5 місяців тому +3

    Love your work, you have helped me a lot. Thank you mate.

  • @jake115577
    @jake115577 Місяць тому

    This is something I should have learned when I was just starting. Thanks as always, Anthony!

  • @viniciushenrique8211
    @viniciushenrique8211 2 роки тому +6

    Damn, this saved my ass today.
    Had to run code line by line and check lots of variables throughout to figure out what was going wrong with a script. As I could only access the machine via terminal in an SSH session, I couldn't use VSCode's debugger.
    Thank you so much, bro!

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

    Love that you were debugging the module you were trying to run. Good example of what happens when debug statements make it in to the code. Which is exactly what pre-commit is meant to prevent. Ahhhhhhhhhh

    • @anthonywritescode
      @anthonywritescode  4 роки тому

      lol yep, big oops there :) but a good result in the end!

    • @sillybuttons925
      @sillybuttons925 4 роки тому

      @@anthonywritescode basically brought this video full circle.

  • @beto5720
    @beto5720 2 роки тому +1

    13:20 thats dope, pre commit saves the day once more

  • @visuals9304
    @visuals9304 2 місяці тому +1

    Thanks!

  • @Quarky_
    @Quarky_ 4 роки тому +5

    Nice video. I didn't know about `return`! Interesting that you find these more useful than conditional breakpoints, that is probably my most used feature. I guess this shows there are many different ways to approach debugging :) Like you, I have never managed to make tab completion work in pdb, I often drop down to full python with interact, but even that is sometimes hit or miss (when it comes to tab completion). Looking forward to the follow-up video on debuggers :)

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

      conditional breakpoints are useful, but so so hard to explain (and usually I just do `if ...: breakpoint()` anyway). I used to have pdb tab complete working, but apparently I thought it was enabled by default in python3+ and deleted it!: github.com/asottile/scratch/commit/d713d95b2aa9af9f40db646788f65db75b7d4ee5#diff-2f794ea6c237446e15b2a2d127706060

    • @Quarky_
      @Quarky_ 4 роки тому

      @@anthonywritescode thanks for pointing to your pdbrc :)

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

    outstanding video anthonywritescode. I killed the thumbs up on your video. Keep up the superior work.

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

    Hey I want to learn how to code python. What do you recommend I do to start? I was thinking about just watching videos here on youtube. I took a cs 102 class which is for beginners in college but it was too fast pace for me as I knew nothing about coding previous to the course and I feel I did not learn from it because like I mentioned it was too fast paced for me and all I did was use chat gpt so I can keep up with assignments.

  • @ДойчеВбанке
    @ДойчеВбанке 4 роки тому +3

    it was helpful for me, thanks

  • @RohitSharma-wx2ky
    @RohitSharma-wx2ky 3 місяці тому

    Any Python question I have had in the past 2 months, there's an #anthonyexplains video for it!! Thabk you!!
    Wanted to ask what's the difference between "type[X]" vs "Type[X]"??

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

    Useful, saved me many times, thanks for sharing!
    Do you plan to make a more advanced debugging video, for example with threads and/or multiprocess library in use and how to debug it from CLI?

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

      debugging threading / multiprocessing isn't easy at all! I've not found a good way to do it personally

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

      @@anthonywritescode Yeah, for me, it's also difficult to tackle. Right now I'm trying to solve it with some success using debugger in an IDE of my choice and works fairly well so far. If I need to debug for example why the thread responsible for sending data to the device under test didn't get proper TCP/IP data. Unfortunately, it's extra hard to do so when you don't have source code for this module because it's compiled using Cython AND you do so on windows.

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

    How do you debug a if statement in general. Also how do you debug a if statement in vs code? I want to see the results of the conditionals tests.

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

      I would either make a conditional breakpoint, or evaluate the condition, or step through it

  • @Naz-yi9bs
    @Naz-yi9bs 3 роки тому +1

    Does it make sense to use PDB or PUDB if your using VSC? Thanks for video!

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

      it depends -- if you can get vs code's debugger working and you're more comfortable using that then by all means go with that route! I still think it's useful to know how to use a terminal debugger and terminal editor for situations where you won't have an IDE available -- but for primary daily-driving debugging an IDE is just fine!

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

    Very good explanation, thank you. And so easy! Why don't more people use this?

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

    Thank you so much, bro

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

    How do i debug my life

  • @s.fariss
    @s.fariss 4 роки тому +1

    Next up.. decorators, please?

    • @anthonywritescode
      @anthonywritescode  4 роки тому

      lucky you! I already made a video about decorators: ua-cam.com/video/WDMr6WolKUM/v-deo.html

    • @s.fariss
      @s.fariss 4 роки тому

      @@anthonywritescode Silly me 😂. I did a UA-cam search the other day in your channel, but somehow, this did not come up.
      Thank you!

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

    Well that was cool. I usually use iPython, cuz it's pretty.