Visual Debugging in PyCharm

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this topic is one that's becoming really near and dear to my heart various features of pycharm are to take something in python that might be a little complex a little bit intimidating and make it a lot more accessible by putting a visual face on it whether it's visual debugging or visual profiling or visual test running etc several of these Python skills that you know you need to learn but don't and I'm always surprised and how many people are still doing debugging using for example print statements this webinar is going to start from that point from the I'm not doing debugging I know I should and then we'll get into some intermediate topics and then depending on time will close out with some more complex extra-credit kind of things and for this for this webinar I'm going to leave my table of contents and markdown visible at all times partially as a cheat for me to help cue myself but also for you to see what I'm talking about and see what I'm going to go through next I'm going to start with non visual debugging using print statements and the command line PDV and then we'll go and solve a problem using the visual debugger and then show how to speed things up we'll go into breakpoints different flavors of breakpoints and then we will go through stepping through code through various different kinds of ways as well as some pretty cool tricks for productive stepping through code we'll entry is the concept of stack frames which grows people for a loop and then show how it can be useful during a real-world debugging session we're going to set some watches which is also another productivity increase then we're going to get into some things that you may not use or may not even know about how can I be bugs something that is not launched by pycharm by attaching the processes the visual testing that I alluded to how can I do visual debugging as part of test-driven development for those that are switching to Python three point five or higher and using type hinting PyCharm can help you on that and will show that boy some of the killer one of the killer features for pycharm professional debugging is setting a breakpoint in the middle of a django or flash template or pyramid will show that and it will get into the integration of debugging and data frames as i have done recently i will show all this in the context of writing a 2-d game using the arcade library which is a wrapper around Piglet nice fun lightweight simple system for writing simple games onward let's get on to old fashioned debugging so if I run this game right now now run it it's going to pop up a window I move my little character around and in arcade everything is from zero zero x and y but where is the zero zero is it up here is it down here let's do some debugging techniques for how I might find the answer to that so for example I might put in a print statement whenever the mouse moves and so now when I run this I'm getting down in the output and I see ok well it's probably down here in the bottom it's not up here in the top well that's one way to do debugging is to use print statements and then start diagnosing problems either in your code or in the Python library code and then you got these print statements sprinkled all over the place and you can't really interact you have to rerun your code to do it again that's when people usually take the stuff up to pythons debugger PDB and they use a set trace to stop execution at this point and let them poke around so now again I run the the game using PI charms run tool window and I can move around and I'm already stopped in that breakpoint and I can print the exposition I can print the Y position that's because in this scope where the breakpoint was set I've got an X and a line relatively straightforward the normal way for the last 24 years of python to do debugging but for many people this is intimidating you got this language that you have to learn for moving things around and then if you want to display where you are you have to run another command to see what position you're at and then as you dive into code you kind of get lost with all these things wouldn't it be nice if there was a visual feature on this I'm going to stop the execution of this game and in the products going to is wrong quick second sure we already have two people asking here it's just code available somewhere I have it in a repository and I questioned whether it would be valuable to share this because it's very little writing of code but you've already answered that two people have asked and so Ernst how about we along with the announcement for the recording we will announce the github repo sounds good we'll put in right walk alright great and as an FYI is a markdown document that's driving all this will be in the repo as well so we just saw old-fashioned debugging how can we run under PI charms visual debugging and then how can we set a breakpoint and accomplish the same task I'm going to delete this line and I'm going to run this under the debugger without a breakpoint just to show that you can run your code without debugging under the debugger if you want to so this I'm going to click the debug game instead of the run game it's going to run in a window very similar to the run tool window but it's the debug tool window you see that it's highlighted here and I can play my game we same as always looks very similar except I'm running it under PI charms debugger instead of running under Python directly when I do that if I'm on Mac OS or I'm on Linux I see this odd thing in the console window what does that mean well I'll take a little digression because it's so super cool over the course in the last two years the PyCharm team has really worked hard on making debugging a first-class experience from a performance perspective one of the first things we did was we share the debugger back again and PI dub with the Eclipse PI dot project and in fact the Eclipse pydev maintainer is the one who is the maintainer of peda and we funded him to do some speed ups on the debugger and fix some bottlenecks and then most importantly have a scythe on option of the debugger back-end which dramatically speeds up the debugger like four times faster on Windows we ship the compiled scythe on speed ups currently on Mac OS we do not nor on Linux but we make it good simple to compile it so if I just click here it will go off it'll run some compilation stuff in the background you won't have to think about this icon compilation process and then for this version of Python wherever it's used in any of your projects in any of your virtual environments it will have those icons speed ups for the pydev back-end so I'll let that run a little bit longer we also did some other speed ups after the site on speed up if you're using Python 3.6 we take advantage of new AP eyes they're available in Python 3.6 to give a rather shocking speed-up thank you to Elizabeth for that and in the latest version of Pi charm we're getting close to the experience of debugging running at the same performance level as running in which case maybe you just run under the debugger all the time so you don't have to do an extra step to do a breakpoint now when I rerun this I don't see that message everything pops up and it feels just as fast as if I ran it not using your mugger I move everything around we're all good let's go back to solving that same task the same problem about where is my zero zero now instead of having to type in some import PD vup TV trays sprinkle around all over the place and navigate it using a clumsy UI I can do visual debugging I can set a breakpoint on that line I can run it under the debugger and execution will stop at that point execution will stop at that point and I get an indication of where I am in the code I get all the local variables in all the various scopes and I get a whole bunch of coolness that we will see during the rest of this webinar so I will stop at this point to see do we have any questions about the speed ups or about visual debugging with a breakpoint we don't have questions about either those solace would you have two other questions right the first one is by rotini to be my apologies if I mispronounce that where can the rkp imported as part of the Python SDK it is a very simple installation I have that open my requirements file movements now here is I have it is as arcade in my requirements file and so then I can pip install it you can also go to your interpreter and use PI spy charms visual approach to installing packages and then you can just all installed arcade it is in pi PI so it's a easy install ok thank you very much the sex question what siphon why is it called siphon siphon is a project has been around in Python whoo for a while I would say at least a decade and it is a way to convert bottlenecks in Python into C code that is very easily integrated into your Python code and what you're doing is performing at the speed of C instead of at the speed of Python alright thank you so much those are all the questions right great all right I will continue on next let's solve a particular problem so if you see here this is the score that I'm outputting on the screen now we'll run this again and we see that here's my game and I see that score is written on the screen zero zero but any of you longtime Python people will know this is the ancient cave drawing version of screen formatting in Python we sure would like to use that cool new syntax that pythons with 3.6 introduced for formatted strings well sure fine charm can help you all and choose the quick fix look how great PyCharm is what's I didn't know that was there I don't really know this in fact I and I have some some on some local scope self-taught score at that point how about I set a breakpoint and interactively fiddle around until I get the correct syntax for that so I'm going to set a breakpoint right here and I'm going to run tree around my code and I'm actually going to rerun it if I mouse over this I see that I can rerun it with command R if I come up here I can also rerun it with command D which controlled the funny bead control D to rerun the debugger from the keyboard I'm stopping at this point I want to poke around until I solve this problem what it what is that that's a F string syntax I don't quite know let's say there's an F and then there's this this single quote string thing then after that I might want to say something directly outputted the literal score and then I think it's a curly brace and then I think I've got access to my scope here so I can say something like self thought score and then there's this syntax where I do a colon and a zero to D and I close my bracket I wonder if that's it evaluate yes yeah that's it my score is zero I've got the expression so I'm interactively exploring using the debugger the programming question that I have well there's another way to do it if you don't want to use that evaluate expression we're stopped in the debugger window down here the debugger tool window and I have access to self dot score and all my variables but I can also go to the console tab and I can turn on the console prompt and let me mouse over that again I'll make my window a little bit bigger so that that appears as I mouse over it show Python prompt that's in the debugger in the debugger console I'm getting a prompt and What's in scope here well I've got a self and I've got a self-taught score and maybe I could do that same thing F score and then self dot score corn zero to D and that works correctly and I could sit and poke around and do all kinds of things the nice reason for doing it with the debugger is sure I could open the Python console and poke around and that gives me access to the code but not the state maybe I want access to the state during execution at that line then I figure out my answer and then I you know take this cut and paste it up here and I like yeah I figured that out yet for me I'm using PI charms terminal completion all that kind of stuff here I Python is much better going to be great if we could use ipython I wonder how hard that could be so I will go ahead and stop this click one time too many all you have to do to get access to ipython in all of your prompts near the terminal python console I'm sorry python console debugger console etc it's just install it so I'm going to go back to that project interpreter I was just fine I'm going to install ipython install package and it's going to go off get the latest version of ipython that was just released I hope that doesn't break anything and then when I come back and do the exact same thing again I'm going to rerun this game stop at that breakpoint go to the console and when I show the Python prompt you'll see that it looks different because I'm now in the magical world of ipython that is not unique to the debuggers console it also the python console hmm so I oh so I already had that one open the Python console is now using ipython as well so I'm going to stop at this point do we have any questions about interactive use of the debugger yes somebody asked is beat pipe and also support it I will give that to your team I don't know I don't think it is I am 95% sure it isn't so I will say it isn't until someone says that it is supported it is not I just got confirmation from the team gratefully you got some right all right and now somebody just asked could you please say again how since all sites and on ubuntu for the debugger you don't need to install scythe on itself it's not like you need that package installed I believe we shipped with a scythe on it's just you need to click that link to do the compilation process yeah I'm 99% sure though that's correct and what is a Python somebody asks I python is a Python package let me go to primary I yeah Python originally a dual headed thing that included ipython notebook now Jupiter notebook they split the interactive console we thing from the web-based notebook thing and now ipython is used to mean the console plane so if I go back to let me just search fine it's a package from the Python community that allows you let's say a rich toolkits for using Python interactively a whole bunch of the features configuration files to govern it a different syntax to go back words and for your previous commands rerun previous commands and a bunch of the teachers for it right great thank you so much all right onward ok breakpoints we already set a breakpoint let's take a look a little bit more in depth these great point things again to solve a problem in Arcade when I'm writing an arcade game using the class syntax I'll make this a little bit I write a game that subclasses from the arcade window and I fill in these magic methods and they do things and the animate magic method is passed a parameter called Delta time but you can choose to use or not use in your method which governs the redrawing of the recalculation of things that need to be redrawn what is this Delta time we can get the explanation if we needed to by going to the super classes slot for it and it tells us the time interval since the last time the function was called ok that sounds pretty good but let's actually explore this for real I'm going to set a breakpoint here and now when I rerun my game using control D I'm going to stop at that point I'm going to observe this value in 0.05 so it was 0.05 seconds since the last time the animate function was called well I've been talking for a while let's go and continue processing past this breakpoint pass this line of execution by saying resume program when I resume program it's going to go hit that breakpoint again why because arcade is calling animate frequently in fact it's calling it every Delta time seconds and since I was talking for a long time it was 26 seconds since the last time it was called because we suspended execution if we go a little faster we see that it's called more frequently than that and if I didn't have the breakpoint it would be called everyone 80th of a second so in this case I used a break point to stop execution at this line take a look at a variable in that scope I could if I wanted to take a look at some other variables for example what's the current score the current score is zero what variables are available on self because I write attributes are available on this instance because I subclass from window well I got some stuff that came from the superclass I also have a sprite list and other things so the breakpoint that we set stopped execution in the animate function gave me a friendly view of the variables that were in scope at that point and allowed me to resume execution let's go solve instead of just poking around to learn let's instead oh actually something I wanted to show resume and now it can fit runs and it doesn't need my help for anything I can move around etc if I wanted to set that breakpoint again do I have to restart my program in order for the breakpoint to be effective the answer is no I don't that's something I see a mistake quite frequently breakpoints are dynamic they're injected and removed at runtime during the execution of your code it's part of the magic of them so now I can remove that breakpoint and continue all right let me stop both of these and say and they're solve that problem right now I accidentally get to the point where I've got a couple of these running all right I'm going to go to my run configuration and I'm going to check this box that says forever and ever never run it more than once so I don't make that mistake now let's imagine that I have a little typo my character the Dora the Explorer I've got a typo in the PNG file name and I run my code I can run it run it under the debugger because the debugger is really fast I'll do control B run it and I'll stop at a breakpoint now note that I didn't create that breakpoint and in fact it's not even in my file it's in a file that belongs to pill or pillow actually library that I installed why do I have that breakpoint here well this is a pretty cool feature of Pi charms visual debugging if I go to the tool window and inspect all the breakpoints that I have set anywhere by default PI charm has a breakpoint that will stop on any Python exception that doesn't get handled by your application or the framework that's calling it I can turn that off if I don't like that support I can also go to the UI and have a very rich UI for managing information about every breakpoint that is set for example this is a great one maybe I want PyCharm the debugger to stop whenever there's an error but only when there's an error in my code not when there's an error in the libraries that I use because you don't want to be stomping all the time it'll get really annoying so that's where that breakpoint feature came from and then I take a look at this and I see why what is it doing why can't it open the file name I gave it the photo yeah but I gave it the wrong file name and if I wanted to see how did I get to here we'll talk about this a little bit later oh this is a very good example of using this feature on the left hand side is a little window called frames in Python when you execute you go into frame of execution when you call a function you go from one frame into a new frame but Python doesn't throw away the previous frame as you go down the layers of the onions Python keeps all of those layers of the onions and all the state that was there and so for example I can go and look to see that is the line that called this line they call this line they call this line that raised the air and in my code the frame that called the underlying library code I see the state of the stack frame and all the variables at that point of execution and as I go through each frame I see all the local data for that part of the code as I keep going down so I'll resume execution and now I know where my error is I can go and fix it and rerun my application oh good news doors back all right I will stop at that point that's a treatment of breakpoints and the UI for configuring settings on them as well as the default you need exception breakpoint all right so you got anything I do when you have to edit a function a couple of people were wondering how do you know it's one eight years of a second it's in the documentation for Arcade that would be an interesting one to go explore around a little bit in the debugger and step through all these things and find out what is it that calls animates how did I get there and what set the default time I'm a contributor to to the arcade library and so I know that you can pass an argument that affects the rate at which animate is called okay but that was not the topic of this discussion it's a topic about arcade all right would you know if there are any differences between visual debugging off bias and 2 & 5 & 3 Python 3.5 or higher is a lot faster if you're using 20 17.1 and if Lizaveta is on the questions maybe she can answer I believe she's got more planned for other things that can be done on that but primarily the behavior is exactly the same it's just a performance difference all right thank you very much all right cool now doors moving around but the purpose of this game is for drawer to pick up some coins we want to put 50 coins on the board it's startup and we want to put them at random positions so we go ahead and start typing our code and our code for this in arcade is I'm going to make a coin list that's a arcade sprite list and I'm going to do a normal eye in range 250 and I'm going to make a new coin using the arcade sprite class and it takes an argument of the file to use for the coin and a scaling factor to make the coins bigger or smaller and then I need to put the initial position of the center of this sprite it's x and y position so I set the center first I want it to be kind of random so I'm going to use pythons random library I'm going to ask PyCharm to import it for me random let me use random in the range of the width of the game and I set my width here to be 600 but I don't really trust this is it really giving me a good distribution of this I'd like to go in and run the game a little bit and have it create some of these 50 coins and take a look at that position let me go ahead and duplicate this to put the lie in as well so I set a breakpoint here I'm going to run my game and since this is in the constructor it's going to stop immediately before the game ever appears and I can see that I've got a coin instance created that coin instance is going to have a lot of data in it but it's going to have a center X that is 191 let's take a look at the next one how can we step through our code and take a look at these X's and Y's for the coins for each of these 50 we're in a loop we want to step through our code so I'm going to use the step over function stepping in debugging is a well-known concept in Python debugging it's well known concept in pycharm visual debugging it's really easy because we have a variety of stepping features with a pointy clicky button you don't have to remember eyes anything confusing so I'm going to step over and go back into my loop and I'm going to take a look at this sensor X is at zero right now that's Ari is it 155 what's the next one going to be the next one is 357 what's the next one going to be 382 so they do seem to be somewhat distributed now as I'm going through this I might decide that I want to know a little bit more about this sprite function what is the zero point to that it's doing what what does that mean what is the effect I want to step into the execution of this clothes code the creation of this class and we have stepped into is a way to instead of going to the next line go into the code that's being executed at this point I'm going to step into that and I see that I'm in the constructor for arcades sprite class and I'm on the first line in there and I can do my same step over go through all of this see how it's all being constructed etc and then when I've done I want to step out and go back to the code that I was on and then I can resume my step over oh I learned a lot about that that's great so I do step over step into step out step into step into oh wait I got taken into the Python standard libraries random module well I don't need to debug random everyone knows what it Suns around forever that was a mistake and that kind of slows down my workflow oh I got stuck going out looking at code I wasn't interested in and now I got step back out wouldn't it be great if I could just choose to step over and into my own code instead of so I've got step over I've got step into step into my code lets me go into functions or classes or modules that are in my package but here instead of stepping into the sprite code it's going to skip it and instead of stepping into pythons random module it's going to skip it and so that's a pretty handy feature and it's letting me do all the exploring that I wanted to do yes I am getting random positions I was able to step over step in to do all my stepping excuse me to learn about that programming question that I have we have other things such as run to cursor where I could put my cursor here and run to that point etc next I'm going to do my collision code so I'm going to take out that breakpoint I'm going to resume here's my game yeah I can still move around Oh actually no I don't have my coins got to put in the last line I need to take this coin and append it to my all sprites hmm what's going on with my execution execute this and I got a bunch of coins on the screen alright next I want to do collision again I can run this I'm moving Dora around she's collecting coins nothing's happening arcade has a collision detection system that we can put in our animate function and so I'm going to tap into that oh my god this is so easy I'm going to keep a list of anything that I collide with using a Archive arcades check for collision with list and my list of things is I've got a player spite is it colliding with anything in the coin lists if there is anything in there I want to process each one of those coins that I collided with and I want to kill it kill it kill the coin and I want to increase my score by one now when I run the game again I'm running it under the debugger because the debuggers fast now it's running around and look my score is going up I'm colliding with coins etc now I want to know a little bit more about how this actually works so I want to step through all the coins in the hit list and understand a little bit more about the score going up keep and watch the score going up to make sure that these scores going up the amount that I think it should so I set a breakpoint here run again under the debugger my game pops up once and as I move around not trigging the breakpoint not triggering the breakpoint trigger the breakpoint how big is my hit list my hit list has one item in it and my score is still let's who tricked you to do my score is now incremented by one and I can continue I want to clear that breakpoint for the next thing instead of going and clicking on it I'm going to go here and delete that breakpoint all right that is all that I have for stepping I'll stop here and answer any questions we have some good questions for you about shortcuts first what is the shortcut to make auto import alt enter on the Mac so for example if I want to say get current working directory which we will do later that's from the Pythons OS library I said alt enter to show intention actions and down there I've got the presentation assistant installed for my webinar that will show you the keystrokes that I'm doing on my keyboard so I'm going to hit alt enter right now I'll enter on Windows and Linux brings up the show intention actions and one of the intentions I can do at this point is import the name study a question you did and there is another question here about the command for duplicating Keys correctly forgetting why I'm sorry implicating lines yep so let's say I wanted to duplicate this line that I'm on I'll just let the presentation assistant answer it for me it's command V uncontrolled users need duplicate line action if I don't want to member all these key commands just remember on Mac command shift a to search for actions I say duplicate there it is I just hit there great then we have another question how to step out from the for loop that is a not a debugger question that is a it well if you want to step out of it without executing any of it then you have to put in a break or whatever in python if you want to stop stepping and go to a line that's after it for example a return and I was on a break point here then I could put my cursor there and use run to cursor all right thank you very much all right good these are all very good questions thanks arts you're welcome once they are just just soul in the breakpoints and looking at variables with sometimes there's data down in a list and whenever I stop I have to go down to it and maybe expand three things to get down to it that's kind of inconvenient so let's do the same thing to see if the coins are actually decreasing let's do the same thing set a breakpoint here and when I run the debugger I was still running oh it's in a zombie State all right so my games running I collide with something I've stopped at the gutter what's my score well crap I've got to expand that scroll way down maybe use the speed surge or I can set what's called a watch expression launch expression can be as simple as a variable and it tells me my score and as I step through it reads that and shows me the answer even shows me the type information for that very handy way to instead of having to look at the big pile of State at the point that you're on in the debugger focus on a small pile of state a watch expression these can be edited directly they can be deleted well that's one good watch expression I'd also like to find out if my coins are actually being reduced it says kill what if kill do I want to go back over and watch the output we stay in my IDE well the coins are being added to a list called coin list what if I added an expression instead of just a variable I want to do a calculation those are stored in the coin list which is in my autocomplete and I want the length of that at the moment it's 49 as I continue through this it goes down as I leave the scope I get an error because score is not an attribute of the scope than Amazon all right so I'm going to continue this back to my game I'm going to move around trigger that thing again and step through my code I'm going to watch the score go up and the number of coins go down I because we're already at 47 I'm not going to go into further depth on watch expressions I will say watch expressions are the the point at which you move from being a beginner debugger to a more advanced debugger you're using the tools of visual debugging to make your life easier for you and your coding more octave Ernst got anything I have enough pain all right I'm going to use a the question of what coin am I on when I am adjusting the position to introduce a little bit about stack frames so for example here when I'm studying the center axe I'm doing it on 50 coins well how does the center acts actually work I'm going to set a breakpoint here now I'm going to run under the debugger again and it's going to smooth it's going to stop at that point I'm going to step into that code well let's say I'm going to step into that code which takes me into random I'm going to step out but I'm going to step in again because Center X is actually a property in our game it's dynamic Center X is a property with a getter and a setter and Here I am in the setter so stepping through code revealed something that was not obvious just by looking at the Python this is a Sutter well what coin am I actually on if I go back in my scope I see that I is zero so I'm on the very first coin I can move back in the frames to get to the point that called this line and see what was the state at that point again in the interest of speeding up I will stop at that point one thing to add as I move through my watch expressions start failing because they are pointing at prop attributes and functions and things that are not available in that scope all right Scott anything for it sure where do I go to get more information about watch expressions the PyCharm help actually has good information on this so if I say pycharm help watch expressions Google will take me to the latest version of PyCharm which is good make sure you don't go to a an earlier version if I went to this the help system will actually do a good job of telling me that I'm out of date let's see my window over here no oh because this page has been refactored that's why there isn't a newer version of this page so everything that I want to know about what is the concept of watches this is the concept how do I create them how do I edit them how do I delete them next question the these not equal arrow operators what are they is at five point three point six syntax let's see if I in guessing that they mean this I think the same thing this is looks weird because this is actually a new I'll say new a new font supported by pycharm called fira code I think we bundle it now and this is a type of font that supports something called ligatures in ligatures are a way to take things that look wrong win typed in say ascii but our programming things and make them for example equal equal now turns into they're all together rather than being split and various other things such as not equal etc or given a different font even though under the hood it's still the equal key plus the equal key 1/x that's all for now thank you so much all right um I'm going to go faster through these because we're getting close and I think we really want to see debugging in Django and flasks if you're into TDD then debugging is great for TDD because usually you're stuck just printing things when you are trying to figure out what's at a certain point in my test so for example I want to go to my tests I can run my tests my unit tests and they fail for several reasons is stopped doesn't exist and I'm thinking to myself man I did that I did support for the is stopped feature where the score it doesn't show until the cursor stops I'm going to prove it I'm going to set a breakpoint right here I'm going to rerun my tests oh I'm running under butter I'm going to run my test under the debugger I wasn't running them under the butter previously it's going to stop at this point and I'm going to step into that I'm in the constructor for my game and I'm looking at see I've got the score oh no I haven't put the is stopped on here yet oh I need to go do that so I've got the benefit of debugging during TDD during test-driven development and I can saw I can help solve a problem about why my test is failing by using debugging to step through my code in the state in my code and interactively poke at things until I fix my tests got any questions for that segment we're going faster so I doubt you do I don't all right great okay let's see I've been running my game I've been launching it under PI sharp and that's great when you can launch things from Python but sometimes there are things where Python might be embedded into something or Kivi or something where it's got its own the launcher and it's not easy to launch under pycharm what if I ran my arcade game I'm going to close that from a terminal I'm doing the terminal in PyCharm it could be the terminal with my operating system if I ran my game not quote unquote under the debugger and it's moving around and all that stuff how can I attached to this Python process from my IDE and do all that debugging stuff that I was just talking about well fortunately the run menu has this thing called attach to local process it gives me a handy listing of all Python things running on my computer I select the one that I want I want it to attach to game PI it's doing some crazy stuff at a very very low level to go and inject itself into a running process and so now when I kill a coin I can set a breakpoint go back to my game and as if by magic because this really is magic I'm debugging a Python process that is running outside of bugs are all right I'll stop at that point got anything I don't okay let's see how go back to my game stop my game make sure the terminal yep it's good okay I'm using Python 3.6 Python 3.5 and 3.6 have type hinting which is really cool I can go and put things for example I can say but this is an int so that everything is completely obvious I can put that this is an end boy this is a drag going around and putting all this information on here constantly Python excels at being your janitor and doing your janitorial work for you does pycharm have a mop to clean up this yes well it actually does I can run something under the debugger run my game under the debugger go and nope that's the wrong process I can run my game under the debugger go do all my stuff much much much tor as happy doors getting rich finish my game and then come up to here and we talked about the quick intention stuff alt-enter annotate types and it while the code was being executed under the debugger it recorded information about this gun during it getting called about the arguments being called about the type of those arguments and offered to fill in the blanks for me and it got all of those right those are the types that I want for those arguments and Delta time what the heck is that thing same thing annotate types I was past a float and I returned nothing so the debugger can be used for other purposes than debugging because it keeps track of information it can collect that information and do the annotations for you one important point let's collect I had to go into a preference and turn that on under build execution deployment Python debugger here is something by default it's not selected why is it not selected Oh mouse-over because it slows the debugger down so I'm going to speed the debugger back up turn that feature off run my code this time as I much much much and go and look for help annotate types oh it remembered it from a previous run but if you don't have that feature turned on if you won't get the benefit of that I will stop there got any questions for me I do this time around first of all something fun Jaime is awesome and okay woo and then that Michelle bus guy asks when will assess your remote process be available don't know I don't think ever I don't know we have I think they're attaching to a process involves some local to your machine IPC protocols that are not available over a network but I will I will defer to your much smarter than me team I will check with the team above but I'll check with the team about this sub process but I'll go back to the first one and say my awesome game awesome sounds good alright I'll go on routine sorry would it be great if I could do debugging and breakpoints and stuff in Django well of course I can it's Python except it's got this template language thing and if I run under the debugger I run my Django signed on to the bugger and go to the UI for it and I go to some screen bla bla bla well I'd like to know a little bit more about what's happening here there's a thing that if I configure some social account providers it's going to say something well what's the value of this didn't I get it set up correctly I sure would like to debunk this would it be great if I could set a breakpoint in a template instead of Python code it wouldn't be great if reloading that oh let's see line on place yeah I think I might be in the wrong spot for that I've done something wrong on this I'd misconfigured this book just before the project and got that wrong so I'll skip it on Django it's the same process under flask where I can run something under the debugger go visit a page and then I can in my loop if I want to see what is the value of tasks I set a breakpoint there reload it what have I done all right I will admit this was working just before I did my demo I don't know if it's because I'm don't think it's because I'm running something over here it's just debugger is active all right I have made a mistake so we all have to go back to the other one and if I can get this fixed and attach it to the recording then I will do so all right next and of course someone might lizabetha might be watching this and knows exactly my stupid mistake all right I can talk a little bit about extra credit since we're already at the limit of time I will show one that's pretty cool is we have a visual debugger webstorm our Java Script IDE also has a visual debugger for JavaScript since PyCharm professional includes webstorm can I do bug JavaScript using the same visual UI using PyCharm so I'm going to go and I'm going to do no js' without a browser first I'm going to open this file and I'll put it on this side and I can run this using no js' I can also debug this a breakpoint right there click debug and nodejs is running instead of python and i've got this same UI with local variables and wash expressions and frames and the console and everything except it's JavaScript so I will continue but what if I have actually a web application with HTML running in chrome instead of a server-side node.js application we also add something called JavaScript debug configuration so I've got an HTML page if I debug this it's going to fire up Chrome and it's going to use a Chrome extension installed in Chrome to connote control chrome from the IDE so that for example if I go to this and put a breakpoint and then rerun mica bugger then chrome stops execution hands control back to pycharm which can't step through the JavaScript code inspect the values all while moving the process of execution through the JavaScript interpreter in chrome I can continue stepping I continue stepping I can continue stuffing and there's my alert all right what else did we have under extra-credit stepping can be configured I can go into my preferences go to stepping and tell it for JavaScript never go into these kind of files in Python never go into these kind of files and add custom patterns and things to the list and all of the things that I'm doing with my mouse for debugging I can actually stop it here instead of stepping with my mouse I can I ran it instead of debug it instead of stepping with my mouse I can step with my keyboard and as I hover over these I see the shortcuts for that I can as I get lost in my code I can click a button that shows that Scrolls me back to my execution breakpoint so for example I'm down here where am I actually stopped I click that it scrolls me back to that point at some point I might have so many breakpoints that I'm I've gotten confused and I want to just run the thing there's an option to mute all the breakpoints temporarily instead of having to go delete them and if I'm sitting on a value and that value for whatever reason might have multiple lines through it like some HTML or a long title I can say inspect pop up a new window and see this in isolation okay that brings me to the best two words of any webinar in conclusion do we have any final questions we do several people ask if you can juice the JavaScript debugging with Django of course you can because it's executing in a way that has no idea that Django is there now if what you're saying is my JavaScript is defined in static assets that are configured in the Django side yes you can you just have to do a little bit more work I'm going to go to the run configuration definition for that JavaScript debug setting and if your Django site is on a different computer or if they are arranged in URL hierarchy that might not be obvious from the pycharm project you can go in here and rearrange your hierarchy to find the original sources all right thank you so much well the questions good loves all right okay so in conclusion this is about visual debugging this is an attempt for beginners to get into Python debugging in a more friendly way with a nice pretty UI and for intermediate people to start picking up some features maybe they aren't using yet like watches and then to go over some things we'll have to show you Jango and flask later but to go over some extra credit things things that you didn't know yet for example debugging in JavaScript which can really help will get the recording up later if you have any questions just ask either on Twitter or in the blog post all right so I'll turn it over you thank you everyone for attending and thanks for using my car yeah thank you so much all right so if you do have any questions later please don't hesitate to reach out to us by email our social media thank you so much Paul for your presentation we all learned a lot I think a lot of people were being very thankful in the questions thing if you would like to get additional information yeah go to Geoffrey's accomplished PyCharm we would appreciate to get your feedback on this webinar so please feel free to send us your feedback on Twitter or in the after webinar survey this reporting will meet of made available on our YouTube channel shoot on soon and at that point we'll also announce it on our Twitter and on our blog our blog is that blog the jet printer complex pycharm if you haven't already check it out on our blog you can find up-to-date pi-theorem news about release and events additional two educational resources so for example the recording of his when we publish there well provide some additional links they were measuring polarization over there including the github link that everybody's been asking for alright thank you very much for joining us today and we like with you too have a great day thanks and goodbye
Info
Channel: JetBrainsTV
Views: 29,784
Rating: undefined out of 5
Keywords: PyCharm, JetBrains, Python, debugging, software development, IDE, developer tools, software developer, webinar
Id: nksiGORLDZw
Channel Id: undefined
Length: 66min 1sec (3961 seconds)
Published: Wed Apr 26 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.