Effective PyCharm (2021 edition) Transcripts
Chapter: Tool windows
Lecture: A much better Python REPL

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's say, I just want a little bit of free form exploration of python.
0:03 Maybe some of the code that I'm writing or something about a package that I'm working
0:07 with, one of the real common ways to do this is go over here and
0:11 open up the python. REPL
0:13 The REPL is the Read Evaluate,
0:15 Print Loop. That's what you get when you type Python 3 and you know,
0:19 you get standard stuff over here,
0:21 you get a little bit of help.
0:22 Like we could come along and say create a variable called abc and then maybe we
0:28 could make some changes to it.
0:33 We come down and we could hit not if we hit it a few times,
0:37 hit half a few times. We do get some help,
0:39 but it's not like I can arrow back and select these.
0:42 I can come over here and say is alpha,
0:45 it's still an auto completed. Here we go.
0:49 Finally. Okay. Yes, it's alpha numeric.
0:51 . Cool. So this is good.
0:53 But what if I want to work with my code from the project that I'm trying
0:57 to explore? Well, I got to make sure I'm in the right directory and
1:01 oh, by the way, I'm gonna make sure I use the right python,
1:05 but that's the wrong python, that's not the one from the virtual environment.
1:08 Well, this is okay. It is far from ideal.
1:13 PyCharm has some really cool features.
1:15 It has the same basic idea with way more things pre configured in a lot more
1:20 help along the way and that's the python console here,
1:24 just make that big. So if we do a quick little line wrap notice first
1:29 of all that is running the python out of the projects virtual environment.
1:33 So it's the right python that has the packages that we've pip installed right over here
1:38 You can see all the various packages like requests and what not that we may
1:44 be working with. So those are all available to us moreover,
1:48 we were down here, there's a couple of things that we've already set a source
1:52 roots. So let's go and make this podcast one also a source root and you
1:56 quick relaunch. Now we can see our podcast is part of the source root.
2:02 Okay, so that's a big bonus.
2:05 Come down here and do the same thing abc but now notice I have all sorts
2:12 of auto complete. So if I want to ask is alpha,
2:15 numeric, yep. There it is and it gives you all the help.
2:19 So if I go over here say join and I can hit show parameter info and
2:24 it'll actually show us all the arguments.
2:26 Though maybe that doesn't really make any sense.
2:28 But you can see that we have our various variables over here,
2:32 we can go even a little bit to de-bugger style here and set the value.
2:36 Like this is a 'new val' and if we print out 'var' again there's a value
2:41 So if you think you might be tempted to open up the python,
2:46 REPL. You definitely should get in the habit of working here,
2:49 let's do one more thing real quick because in our podcast folder over here we have
2:53 this service, we can just say import service.
2:57 I noticed we get auto complete for that and then we go to our service and
3:02 say dot this is all the stuff that we were working on in that podcast demo
3:06 how cool is that? So remember we had to download information,
3:09 we could ask things about, you know,
3:11 what is the max episode IDE.
3:13 And whatnot. So we come over here and say download that.
3:16 Actually went out to talk python and python but it's one of the two and downloaded
3:21 it. And then we could say um num is something like this num= service.get_max_episode_in( ).
3:26 What is the number 329.
3:31 And then we could get information about it.
3:34 Look how much easier this is.
3:35 All right. 329. And there's the whole episode of the title and whatnot.
3:42 You can see the variables that were coming up with here.
3:45 Like if we had stored that into a variable,
3:49 we could see, you know,
3:50 go over here and explore it.
3:51 We also have what's called special variables.
3:54 These are like the Dunder things Dunder,
3:56 name, Dunder file and so on,
3:57 but also the module we imported.
3:58 So for example, here's all the episodes that we've downloaded,
4:03 what we did. The download info.
4:05 Hopefully you see how valuable this is and how much of a butter experience it is
4:09 Then just typing python, especially if you want to work with specifically your code
4:13 your environment, your packages.
4:15 So be sure to make good use of this.