Flask is a micro-framework written in python. Flask is based on the Werkzeug WSGI toolkit and Jinja2 template engine. It is called a micro framework because it does not require tools or libraries. Flask supports various extensions that can add additional functionalities. Few applications that use flask are

  1. Pinterest

Disadvantages of flask

Some of the major disadvantages of the flask framework are,

  1. Not suitable for big applications.

These disadvantages are based on comparing flask with Django. …


Photo by Hitesh Choudhary on Unsplash

The string module has some of the built-in constant variables. We can use this instead of declaring the constants again in our code. Some of the string constants that will be discussed here are,

  1. ascii_letters

Let us look at these constants one by one with a code snippet printing each of these string constants.

1. ascii_letters

The ascii_letters constant is the concatenation of both lowercase and uppercase alphabets as a string. Let us import the string module and print this constant.


Photo by Behnam Norouzi on Unsplash

The calendar module in python enables us to print calendars on the terminal and other cool functions with the calendar.

Import the calendar module to access all these functions.

import calendar

Print a month’s calendar

The prmonth() method helps us to print a month’s calendar. It requires the year and the month in the form of integers as arguments.


Photo by Annie Spratt on Unsplash

The math module provides us various functions. Some of them are discussed in this article. Import the math function to begin.

import math

The ten methods in this article are

  1. ceil and floor

Ceil and floor functions

The ceil() method returns an integer that is greater than or equal to the given float value. Similarly, the floor() method returns an integer that is lesser or equal to the given float value. If an integer value is given the same value is returned.


Photo by Chris Liverani on Unsplash

Python has a built-in library called statistics. This module provides functions for calculating mathematical statistics of numeric (Real-valued) data.

Unless explicitly noted, these functions support int, float, Decimal and Fraction.

Some of the most common methods supported by this module are,

  1. mean()

Let us look at the above methods one by one with an example for each.

1. mean()

The first method is the mean(). This method returns the sample arithmetic mean of data which can be a sequence or iterable.

The arithmetic mean is the sum of the data divided by the number of…


Photo by Nick Fewings on Unsplash

I was always amazed by how easily things can be done using python. Some of the tedious tasks can be done in a single line of code using python. I have gathered some of my favorite one-liners from python. I have listed out 50 of them below with an example for each.

1. Anagram

from collections import Counter

s1 = 'below'
s2 = 'elbow'

print('anagram') if Counter(s1) == Counter(s2) else print('not an anagram')

2. Binary to decimal

decimal = int('1010', 2)
print(decimal) #10

3. Converting string to lower case

"Hi my name is Allwin".lower()
# 'hi my name is allwin'
"Hi my name is Allwin".casefold()
# 'hi my name is allwin'

4. Converting string to upper case

"hi…


Photo by Firmbee.com on Unsplash

This blog post focuses on finding various information about the nature of the browser and os from which the HTTP requests are made. The following information can be obtained from the requests.

  1. If the device is a mobile/PC

Let us get started. There are actually two ways to obtain this information.

  1. The 'HTTP_USER_AGENT' header data from the request object

Let us get started.

1. The 'HTTP_USER_AGENT' data from the header

In Django, each type of HTTP request is received at the backend via a request object. This request object…


Photo by Laika Notebooks on Unsplash

This article is about copying the contents of one file to another using python. This is possible with the help of a built-in python library called shutil. This library just copies the contents of the source file to the destination file in a single line of code.

How does it work?

The shutil module has a method called copyfile(). This method takes the source file name and the destination file name as the parameters. The copy of the source file is made in the same directory as the program unless a complete path is given as the destination file name.

code


Photo by Solen Feyissa on Unsplash

Is your inbox cluttered with promotional emails or newsletters from websites that you cannot unsubscribe to? Don't worry there is a way to hide these emails from your inbox.

Gmail inbox filter

Gmail enables us to create advanced filters to filter our emails. With the help of the filters that we created, either we can apply them to the inbox in case we only need to perform a search or we can specify certain actions to the filtered emails.


Photo by Jørgen Håland on Unsplash

I recently came across a situation where I had to copy my virtual environment and paste it into another directory. This worked perfectly fine. But I noticed that the VIRTUAL_ENV path inside the “activate” file was still pointed to the original directory from where it is copied from.

I searched for ways to completely clone a virtual environment from one directory to another. The following method was much simpler and worked perfectly fine.

How does it work?

  1. Install the virtualenv-clone inside the virtual environment which you wish to copy elsewhere.
$ pip install virtualenv-clone

2. We need to run the following command providing the…

Allwin Raju

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store