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
Some of the major disadvantages of the flask framework are,
These disadvantages are based on comparing flask with Django. …
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,
Let us look at these constants one by one with a code snippet printing each of these string constants.
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.
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.
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.
The math module provides us various functions. Some of them are discussed in this article. Import the math function to begin.
The ten methods in this article are
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.
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
Some of the most common methods supported by this module are,
Let us look at the above methods one by one with an example for each.
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…
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.
from collections import Counter
s1 = 'below'
s2 = 'elbow'
print('anagram') if Counter(s1) == Counter(s2) else print('not an anagram')
decimal = int('1010', 2)
"Hi my name is Allwin".lower()
# 'hi my name is allwin'
"Hi my name is Allwin".casefold()
# 'hi my name is allwin'
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.
Let us get started. There are actually two ways to obtain this information.
'HTTP_USER_AGENT'header data from the request object
Let us get started.
'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…
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.
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.
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 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.
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.
$ pip install virtualenv-clone
2. We need to run the following command providing the…