Build a platform
http://interform-uk.com/materials-and-finishes/ There is nothing to stop you installing Python on your Windows machine and start coding immediately. However, to keep things clean, I tend to set up a virtual environment to play around with. You basically have two options here, which can be combined for further flexibility.
- Run code in a VM. Install VMware Player/Workstation or VirtualBox, get a Ubuntu server ISO downloaded and create a VM you can play about with. Unbuntu also comes with Python pre-installed
- Run code in a virtual environment. Pyvenv and Virtualenv are tools that allow you to create virtual Python environments, different from your core installation. You can install additional modules, discussed below, without interfering with your core installation. Once you have finished, simply delete the directory and its done, meaning you can always build a fresh environment very quickly. Very useful for trying out new modules and projects multiple times without having to build a new VM to clean things up
You can of course do both of the above i.e. run virtual environments within your VM. As an extension of option two, there are tools out there that allow you to install a core installation of Python and from there you can install virtual environments not just for modules but also for different versions of Python. An example of this is Anaconda. The main advantage of this for me is that, despite me working predominantly with Python3, I can create a Python2 environment and test code I find online to my hearts content straight away, rather than having to change the code to Python3 before I can start testing it.
I have Anaconda installed on my Windows machine and have various Linux VMs with both virtual and core only installations to play about with. Give them a try and see what works for you. They are all surprisingly easy to get up and running.
Extending the core functionality
Modules are a great way or extending the functionality of your chosen language (note different languages may call them something different, but it applies to both PowerShell and Python). Eventually, you might even get around to writing your own so you can create functionality that you can copy and paste in different scenarios. This is one of the key benefits of coding i.e. not reinventing the wheel each time you tackle a problem.
An example would be how to use Python to interact with a web server. Perhaps the most popular way of doing this is using a module called Requests. This very useful module abstracts a lot of the under the hood code and provides an easy to use interface to build request types, add authentication and headers without pain and work with returned results. There are many modules that come with the Python standard library and 100s of 1000s more available online.
When you are wondering ‘how do I achieve x using y?’, Google will often have a good answer because chances are, somebody else has already thought about it. For example, if you end up trying to write a script that interacts with an API, you might run in to a problem that your script is not being too helpful about. Postman (plugin, requires Chrome) to the rescue. It allows you to test API functionality in a more user friendly GUI and quickly change parameters. It’s saved me a couple of times, without me having to butcher my script on the fly and I can see what I’ve done wrong then apply the required changes to my script.
Also, Google doesn’t judge so ask as stupid a question as you want. Chances are somebody has actually had the cheek to ask this on a forum such as StackExchange without having done any real investigation themselves. Try not to be that person though. Do your own exploring before asking for ‘live’ help, because people are much more inclined to help those who can demonstrate that they have tried to help themselves first.
Part 4 has hopefully opened your eyes to the fact that there are lots of tools available to you to make your coding journey easier and more enjoyable. The above list doesn’t even begin to scratch the surface but should give you a poke in right direction.
Till the next time.