Save Your Environment
Why Is It So Dang Hard to Get Started With Python?
A common critique of getting started with Python is how hard it can be to get up and running. It would be great if you could download a thing, code some stuff, hit a button, and voila!
But alas. It's not that simple.
First Things First
It's hard for me to remember at this point what I did exactly to get started. I wish I would have written it all down!
Good thing I started this blog for all things going forward.
Anyway, if I had to do it all over again, here are the things I would like to know before even starting one line of code.
- What is an IDE and which to choose
- Where to get the latest version of Python
- When to use a "virtual environment" (hint: maybe always)
- Why code format matters
- How to code some Python, finally...
Got all that? Okay, fine... A little more detail.
Choosing an Editor
When you get started, you may want to choose an application to use for coding. Most commonly, this will be a code editor or Integrated Development Environment (IDE).
Don't get overwhelmed with all the choices.
Bottom line: There's too many choices. If you don't have a background as a developer (like me), there's likely way too much information to sift through that will be mostly irrelevant to you.
My advice is just choose one. Learn it. Stick with it. Break it. But mostly, just use it. Some are fairly basic, others more robust and fully-featured. However, if you want to code, you will want to feel comfortable doing so.
Get the Latest Version of Python
Okay, so this sounds simple enough.
You get into all sorts of scenarios depending on whether you have a Windows or MacOS machine (or something else) and from where you choose to install Python.
Here's the main thing I would say.
Just make sure that after you install Python, you leave it alone.
When you get a new version of Python, you want to leave it untouched.
What I mean by that is that, as you get to using Python, you will inevitably be adding to its functionality by a plethora of packages that have been created by the Python community.
I didn't quite grasp the breadth (and awesomeness) of this reality.
It becomes even more important as newer versions of Python get released.
For now, I'll offer a bit of advice (if you're on Windows).
If you chose to install directly from python.org, make sure to also install the "py launcher" that comes bundled with the official Windows version. It could save you a lot of headaches in the future (particularly when working with different versions of Python).
Read this for more context:
Virtually Environmentally Conscious
So yeah, about keeping that Python installation clean...
It's really important!
There may be very rare exceptions to that, but if you're new to the game, just trust me on this one.
Once you are up and running with your code editor of choice, the first thing you should do is learn/memorize how to create and activate a virtual environment.
What does that mean?
When you first download Python, you want to keep that version in "mint condition." Creating a virtual environment means that you are taking a "replica" or copy of your Python installation.
This allows you to use this copy to install those aforementioned packages and customize for the specific project you are working on.
Do it any time you start a project, as simple as it may be. Make a virtual environment. Activate it.
If you're doing it in the terminal (all the cool kids are doing it these days), this piece of code will be your best friend:
py -m venv venv
If you installed Python and included the py launcher mentioned above, the
py command will point to your latest version of Python installed, regardless of where you installed it. (You can later use that command to find older installations, which you may need to do if you plan on sticking with Python for the long term.)
I admit, I don't really know what PEP stands for (I know I've Googled it, just wont commit to memory yet). I won't go too much in depth here, but the main take away is that there are some general guidelines as to how to code in Python.
But I'm not even talking about coding in a Pythonic way, per se.
I mostly mean it in a very basic sense. Rules and guidelines for code format in Python are meant to keep your code readable and accessible. It's good practice even if you're the only one that sees your code.
For example, as of now, I have been a solo coder in my own little bubble. But I can't stress this enough. You will be doing yourself a great favor if you keep your code neat and readable.
Learn to write your code in such a way that you can come back to it and immediately pick up where you left off. If not, you'll be hurting yourself in the long run.
This I know by experience.
Finally, Code Some Python
That's about it, actually. I'm not going to tell you what to code.
If you want to learn how, there are a multitude of places you can go. This site might be one of them. But don't sell yourself short. Use every resource at your disposal, but mostly your own brain.
The point here is that you truly will benefit most once you start using the code as much as you can.
Coding can be fun. Don't hamstring yourself by glossing over some of these steps. The less barriers you have to overcome between you and your shiny new app, the happier you'll be.
I mean, sure, if you're only thinking about "Hello, world" at this point, then maybe all of this was overkill.
But on second thought, probably not...