Code Monkey home page Code Monkey logo

visual_debugging's Introduction

Visual Debugging Webinar

  • Debugging without PyCharm's debugger: print and pdb
  • First use of the debugger (and the Cython speedups)
  • Breakpoints
  • Using the console/IPython at a breakpoint
  • Conditional breakpoints
  • All flavors of stepping through code
  • Moving through stack frames
  • Setting watches
  • Attaching to processes
  • Debugging during testing
  • Extracting type information
  • Django/Flask template debugging
  • Viewing numpy/pandas data frames

Old-Fashioned Debugging

  • Problem: Where is 0,0
  • print statements
  • import pdb; pdb.set_trace()

Visual Debugging

  • Run program like normal, under the debugger
  • Install Cython speedups
  • Use breakpoint to solve first problem

Poking Around

  • Problem: I want to use f-string f'Score: {self.score:02d}' but I'm not sure how
  • Interactive would help
  • Set breakpoint, then use Evaluate Expression
  • Or, Console
  • Install iPython and use it

Breakpoints

  • Problem: What is that "delta_time" thing?
  • Set breakpoint, observe value, click "Continue"
  • Clear breakpoint, click "Continue"
  • Problem: wrong filename, what directory am I in?
  • Any Exception breakpoint

Stepping

  • Problem: 50 coins at random positions
  • Add for loop, but is random doing the right thing?
  • Set breakpoint, start regular stepping
  • Set breakpoint outside, and step into
  • Ditto, step over
  • Problem: How does Arcade collisions work?
  • Add code then step into

Watch Expressions

  • Problem: Are the number of coins actually decreasing?
  • Set breakpoint in for coin in hit_list
  • Add a watch expression: len(self.coin_list)
  • Cause collision with multiple coins
  • Step through and see the watch expression value

Stack Frames

  • Problem: Which coin is in _set_center_x?
  • In for loop, step into setting the x
  • Move back up the stack
  • Observe the watch expression and self.score

Debug During Testing

  • Problem: TDD for "Don't show score when mouse is moving"
  • Write a test to see if score goes up on collision
  • It fails, I'm confused
  • Use debugging
  • Fix tests, clear breakpoint, re-run

Attach to Process

  • Run game.py from command line
  • Use "Attach to Process" and then debug it

Extract Type Information

  • Preferences -> Build -> Python Debugger, checkbox for Collect

Django and Flask

  • Open Flask project
  • Set a breakpoint in a template

Extra Credit

  • NodeJS/Chrome debugging
  • Configuring Stepping
  • Keyboard shortcuts for stepping
  • Show Execution Point button in toolbar when you get lost
  • Mute Breakpoints button
  • Inspect watch value in separate window

visual_debugging's People

Contributors

pauleveritt avatar theslimshaney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.