Check out a free preview of the full Python Fundamentals course
The "Opening the Project and Python File" Lesson is part of the full, Python Fundamentals course featured in this preview video. Here's what you'd learn in this lesson:
Nina demonstrates how to set up a basic file structure, create a python file, and a few handy keyboard shortcuts for VSCode.
Transcript from the "Opening the Project and Python File" Lesson
[00:00:00]
>> Nina Zakharenko: Let's open up our first project, let's change to our home directory, for Windows that's cd space $home. And then enter the Py workshop folder from the last step, the directory that you just created. We're gonna activate our virtual environment, should already be activated. Now we're gonna open a project from VS code in the command line.
[00:00:28]
So from that project directory we're gonna type code space dot, this should open the project in the current directory. And this is the last time we're gonna be using the terminal outside of VS code for the duration of the course. Now if for some reason this isn't working for you or you're getting a permission denied error or something like that, you can just open VS code from wherever you installed it.
[00:00:55]
Just double-click on the application and then navigate to File, Open, and open this PyWorkshop folder. So there are two really important keyboard shortcuts that you'll need to remember for VS code and that's it. If you have Notepad open or a piece of paper, I recommend just writing them down so you have them handy, the command palate.
[00:01:22]
So on Mac, that's command shift p, on Windows, control shift p. This is just your map to VS code, you can type any command in here and it will just easily narrow it down. Anything that you might wanna do, you'll find from the command palate. The next is the open file dialog, on Mac, that's command P, on Windows, it's Ctrl P, and that will easily let you open any file in your project.
[00:01:51]
And as you type it'll narrow things down.
>> Nina Zakharenko: So that's the basics of VS code, a little bit about working with Python. Where the first time that we open a Python file in VS code, we're gonna get some configuration pop ups. For the time being, make sure that you don't dismiss them cuz we're going to take action for them.
[00:02:17]
So let's make a new file called project.py in the Py Workshop directory.
>> Nina Zakharenko: And if we wanted to do that from VS Code, there is a built in terminal. I know this via the keyboard shortcuts, on Mac it's CTRL + backtick and on Windows it's CTRL + single quote.
[00:02:40]
So that should drop you into the py workshop directory right here in the terminal. And on Mac, we can just say touch project.py, and that'll make a new Python file here.
>> Nina Zakharenko: Or you can make a new file via this top left icon here, that's your explorer. You can just select the right folder and then hit this new file button.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops