The journey begins
Welcome to your first day of 30 Days of Python! Whether you're new to Python or you want to take some time to review the fundamentals, I'm sure you'll enjoy this series.
In this post you'll set up your environment so that you're ready for the first day of Python content.
The first thing is to set up a development environment. That includes an editor, where you’ll actually write code, and some tools for debugging and running your Python programs.
For the entire series, we’ll be working in an online editor called repl.it, which includes everything you need to get started. You don’t even need to make an account, although personally I’d recommend you make one anyway.
For everyone else, here are a few things you need to know about using repl.it.
How to use repl.it
Creating a repl
Projects on repl.it are organised into workspaces called repls. Repl.it offers repls for many different programming languages, so make sure to create Python repls when you're following this series.
To create a new repl, click the “new repl” button in the top right hand corner of the page. You can do this whether you’re logged in or not. If you create an account, it'll be easier for you to find past repls since they'll all be listed under your profile.
After clicking the button, you’ll get a pop up which looks something like this:
The drop down menu on the left gives us a whole host of different repl types we can make. Notably, we have more than one type of Python repl we can make. We want to select the option which says “Python”, which will create a standard Python 3 repl.
Make sure you don’t select Python 2.7, as there are some significant syntax differences between Python 2 and Python 3, and some features we’re going to be talking about simply won’t work.
If you like, you can name your repl, which can be useful for organisation, but if you leave this field blank, repl.it is going to name the repl for you.
Click “Create Repl” when you’re done, and you’ll be taken to your new workspace.
Some additional configuration
Once you’re inside your new workspace, you can do a bit of extra configuration to make Repl.it ready for Python development.
Click the little gear icon on the left hand side of the screen. That displays a pop out menu like this:
There’s only one important setting to change here: the indent size. This affects how many spaces get added when we press the tab key.
Indentation is very important in Python (as we’ll soon see), and Python’s standard style stipulates that we use four spaces. We therefore need to change indent size to “4”.
There are also some optional changes we can make in this menu. I like to have the console window (where our code's output will be shown) below the code, so I change the layout setting to “stacked”. Feel free to play around and decide which layout you prefer.
You can also change the font size from extremely small to unreasonably large, so choose whatever you find most comfortable to read.
The final thing worth mentioning is the theme. By default, repl.it uses a light theme, but if you’re a night owl like me, you can change the theme to “dark”.
Running your code
Once you’ve written some code and you want to run it, press the “run” button in the top bar. It's important to be aware of is what is going to run.
Repl.it will always run the file called
main.py, which is added for us when we create a new repl. For this reason, I’d recommend you create a new repl for every new program you want to write. If you want to keep things organised, you can make use of the built-in folders for grouping repls.
Sharing your code
One of the really cool things about Repl.it is that it makes it very easy to share your code with other people. All you have to do is share the link to your repl. Don’t worry, the people you share it with won’t be able to edit your work.
If you want more information about how to use and configure Repl.it, there are some extensive documentation pages you can check out.
With that we're done setting up Repl.it, and we can start writing some Python. Hopefully set up was relatively painless, and I hope you enjoy the rest of the series!
Get started with day 1 here.