Python Memory Management and Tips Transcripts
Chapter: Python variables and memory
Lecture: Loading the sample code

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now finally, let's write some code,
0:01 as we're going to do for much of the rest of this course and explore
0:05 these ideas. But before we actually start writing,
0:07 I want to just show you how you can work with the code from GitHub
0:10 and just get it started if that's somewhat new to you.
0:13 So over here, we've got our code structure. Now,
0:15 right now, these are all empty.
0:16 I just have little placeholders, so Git will create the folders.
0:19 Git only tracks files, not folders.
0:21 So this is the trick to make it create them for me.
0:24 What I want to do is just open up this entire project here in PyCharm.
0:29 Now, the first thing I want to do in order to do that is
0:32 create a virtual environment. We're not actually going to need the virtual environment for quite a
0:36 while, but let's go ahead and just start out that way.
0:38 So I'm gonna open a terminal here in this folder.
0:42 I checked it out as a mem-course not
0:43 its full name, but I'm gonna create a virtual environment.
0:46 So, python3 -m venv venv,
0:53 and we want to activate it. On Windows,
1:00 this would be the same. Sometimes you drop the three.
1:03 This would be scripts, and you wouldn't do the dot.
1:06 It always turns out that whenever you're creating a virtue environment almost always pip is out
1:10 of date. That's super annoying, though we just want to make sure that we're going
1:14 to upgrade pip. Alright,
1:19 now we're ready. I'm gonna take this directory mem-course and drop it into
1:23 PyCharm. And because of the way I put it over here,
1:25 it's kind of annoying. You can't get back to its super easily.
1:27 So if you right click up there,
1:28 you can get a hold of the course.
1:30 I'm gonna drop this on PyCharm.
1:32 Now, on Windows and Linux,
1:34 you can't do that trick. Just go file, open directory, and select it.
1:39 Now, for some reason, it found the wrong virtual Environment, so
1:42 I click here, add interpreter, pick an existing one,
1:48 go to my project directory. Sometimes it gets it right.
1:51 Sometimes it doesn't get it right.
1:58 Perfect. So you can see it's running down here,
2:00 and it looks like it's probably the right thing.
2:03 So let's go down here and we're gonna just add a quick little function that we
2:06 can, file that we can run just to make sure everything is working.
2:10 I'm going to call all the things that are here that are meant to be executed directly
2:13 "app_something" and then there's gonna be a bunch of libraries that they
2:18 use but maybe don't get executed directly,
2:20 and those will just be whatever their names are.
2:22 So that's the convention. I'm gonna try to make it clear what you can run
2:25 in here and what you can't. So I'm gonna call this "app_size".
2:30 And then as a good standard practice,
2:32 we want to create a main method we want to use the "__name__='__main__'"
2:35 convention. I've added an extra personalized little live template to PyCharm
2:42 so I don't have to type it. So you'll see me type "fmain",
2:44 and if I hit Tab, it writes this for us.
2:48 You could write that yourself, but it's super annoying to write it all the time
2:50 So I'm gonna write this and we'll just print out.
2:55 Right click, Run. Looks like we're using the right python to run our little project.
3:00 Cool. So now we've got our projects open.
3:04 Once we get stuff in here, I'm gonna be deleting these,
3:07 but that's how you open the code.
3:09 Of course, you'll have the code already here,
3:10 but then you could just go right click and run the various things that you want
3:13 to explore.