Posts

Time and Timezones in Python

Image
Processing of time information is often a critical part in a Python application. In this post, we are going to solve the following problem: Given the departure time and the duration of a flight from New York to London, find the arrival time in London local time. Departure New York: Jul 23 at 19:30, 2018 Flight time: 7h 15min   The final output will be Task: Find the arrival time in London local time. To solve this problem we need to consider time zones. And that can be a challenge. Time zones are not fixed, they change depending on political decisions. For example, during the summer in New York the time zone respected is EDT (Eastern Daylight Time), but during the winter the time zone EST (Eastern Standard Time) is followed. The situation is similar in London, during summer the BST (British Summer Time) is used and in the winter GMT (Greenwich Mean Time) is followed. When does the summer end and the winter start? Well, that’s not based on meteorologica

Setting up a virtual environment in Python

Image
In this post, we are going to set up a virtual environment in Python and as an example install Django 1.8.18 (LTS). Although you can set up a virtual environment in any distribution of Python, in this post we are going to use WinPython, a portable version of python that you can run from a USB drive on any Windows machine. No installation or special permissions are required! If you already have a Python distribution installed that you want to use, you can skip to step 2  and just install virtualenv . 1. Install WinPython Download your choice of WinPython from sourceforge.net. Here I chose WinPython-64bit-3.6.2.0Qt5.exe . Run the exe file and you will have a folder as shown in the image below. During the installation, or rather unpacking of the files, you must choose a destination folder. Here I chose to unpack the files to a folder called WinPython-64bit-3.6.2.0Qt5 that is located in the root of my drive, in my case d:\ WinPython-64bit-3.6.2.0Qt5 \ . Although the folder

WinPython - Portable Python that you can run from a usb drive on any Windows machine

Image
In this post, I will show you how to run Python from a USB flash drive on any Windows machine using WinPython. If you have any previous experience with Python, either from data manipulation or maybe from some of the Python classes offered by Coursera , then you will be happy to know that WinPython by default includes: Pandas - Python Data Analysis Library: SciPy - An ecosystem of open-source software for mathematics, science, and engineering Spyder   - An interactive development environment scikit-learn - Machine Learning Additional packages can often be relatively easy installed. After you installed WinPython you will have a directory on your flash drive, or on your hard drive, that looks like in the image to the left. Jupyter Notebook is included, together with the IDLEX development environment. You can also run Python from the console, i.e. command prompt, directly from your USB flash drive, on any Windows machine.                 Installati