Alright, so what kind of work environment do we need to be efficient at
programming with Python? The question can be posed for any programming language
really, and so the answer is usually going to be same.
I mean feel free if you want to, to open up notepad on Windows or you know some
basic text editor and write a script and go over to the terminal and command prompt
and run it, however that's not efficient for a variety of reasons.
So, what we're going to be using is an IDE, which stands for integrated
development environment, and we're going to be using Jetbrains PyCharm. Now,
PyCharm is free for, I spelled that wrong
just go to Google, search PyCharm, and click on the link there which is from
jetbrains.com, and you can download it. Now when you get to the download screen
you're going to get a professional or community version, choose the community
version that is free, it's completely fully featured as far as i can tell, and
that's the one that we're going to be using in this video. Now
alternatively I mean you can go have a look at other IDEs for Python, but I find
that this one it just works really well, it's simple, and it does everything that
we need it to do, and it also has some advanced features which we may look at
some point in the future. So, go ahead download the installer for your platform,
it does require Java as well, so you can just open up Google and type download
Java, and it's going to take a java.com/download if you click that link, just
click download the appropriate version for your system, and once you
have that installed then you can install PyCharm. So, let's take a walk around
PyCharm right quick.
So, this is going to be the first screen that you see every time you start up
PyCharm. The first launch screen is a bit different you can choose a theme and
whatnot,
all that is relevant really. We're going to create a new project, it's going to be
pure Python, now there's also other options here if you want to start a
Django project, etc., but we're just going to start a Python project here and we're
going to choose version 3.5.1 which is also going to tell the IDE
here where to find the binary files to run Python. Now, we're also going to name
the project here, so first program, and this is going to be the name of our
project. It's going to create a folder called first program and this is how
we're going to identify it within here. So, along the left-hand side here this
is the project view so let's go ahead and right click and create a new file.
Now,
additionally you can create a new directory, a Python package, and a bunch of
different file types here. We're just going to choose a Python file and i'm going to
name it main, which is going to name it main.py, and here we can start typing
our script. So, again i'm just going to use the hello world example, and that's
all it's going to be. I'm going to save it, keyboard shortcuts are going
to take you a long way if you're going to become a programmer, so I expect you
know some already, if you don't on Windows Linux control + S saves the file
and on OS 10 its command + S so you don't have to always go through the menus and
stuff, but let's have a look through the menus. If you want to create a new
project, a new file, or directory you can open one etcetera, you can actually
access the settings by going to default
settings for this project, and a bunch of different options down here that we
don't really need. If you go to edit you're going to see you can undo and
it's also going to show you the corresponding keyboard shortcuts for
each one of these options, so this is command + Z and that's going to undo
whatever action I previously did, this is also going to be useful if you're going
to become a professional programmer. Same is true for copy, paste, find. We're going
to be discussing find at some point, I mean it's a pretty powerful command you
can find not only in the current file but your entire project if you want to
look for instances of variable or string or something you can actually search
through the entire root directory of this project if you want. If you go to
view and go tool windows here
is what we're looking at here project if we select that it's going to,
it should hide that, yeah, so it hid the project sidebar, so we're going to leave
that open. Now, we can also show favorite structure, etcetera. If you have version
control setup this will not be disabled and you can use that to perform first
control actions.
We're going to open up a Python console here and here we can actually run Python
code. If we wanted to say 5+5 you know and it's going to return that so this is
the interpreter itself, however if we want to actually open terminal we can
open a terminal here and here we can just type python3 main.py and it's
going to run what we have up in this file right here. Now additionally we have
a run right here. We can set up run, a run configuration here, to actually every
time we hit the run it's going to automatically run our projec,t so let's
go ahead and hit the plus sign, choose python,
and it's gonna be called a Python run, script is going to be python3 or the
script is going to be the the actual python script that we want run so it's
going to be main.py, script parameters this is if we're passing in any arguments or
anything we're not going to it's already found the Python interpreter because
when we set up the project we chose the correct Python version. This is going to
be interpreter options we're not going to be using any, and that's all that we
need to do. So, let's go ahead and click apply and then run, and it's going to run
the script, output that, and then it says it finished with exit code zero which is
completely normal.
So, every time you want to run if you have this little section opened here
just hit that play button, the Run button there, it's going to run the code
in real time. So, make changes, hit ctrl + S, and then run the code right there, this
is the most efficient way to run a program in an IDE, you know, you don't have
to switch back and forth between windows and stuff. So, this is the primary reason
that we're going to be using this IDE for the sake of this course. Again, feel
free to have a look at some others but I recommend if you're a complete novice to
any of this
just follow along exactly with what I'm doing and you shouldn't have a problem.
However, if you do there's a discussion section to the right of this video, use
it, let me know if you have any trouble, and I'll try to clear it up.
So, with all that said we are finally ready to actually get in to the language
itself.