Home » Python (page 2)

Python

Python Operators: Arithmetic, Comparison, Logical and more

Operators refer to special symbols in Python that carry out arithmetic or logical computation. An operand is generally a variable or a value on which we operate. 1. Python Operators There different types of python operators and we will discuss some of them below. Python Arithmetic Operator Python Comparison Operator Python Logical Operator Python Identity Operator Python Bitwise Operator Python ...

Read More »

Using Python to Make Art With Math

Math can be intimidating. Depending on the teacher and how it is taught, it can be an infuriating combination of inscrutable and boring. But, there’s a beauty to math—a symmetry to the intelligence and logic behind numbers. I love math, and I want other people to love it too. One neat way to make math more approachable and show its beauty ...

Read More »

Boto3 – Amazon S3 As Python Object Store

Use Amazon Simple Storage Service(S3) as an object store to manage Python data structures. 1.Introduction Amazon S3 is extensively used as a file storage system to store and share files across the internet.  Amazon S3 can be used to store any type of objects, it is a simple key value store.  It can be used to store objects created in ...

Read More »

PyQt5 tutorial – Python GUI programming examples

In a previous tutorial, we talked about the Tkinter module and we saw how to build GUI apps using it. In this tutorial, we will continue building graphical interfaces in Python and this time we will use PyQt5. PyQt5 is one of the most used modules in building GUI apps in Python and that’s due to its simplicity as you ...

Read More »

Invoking Ansible Inside Python Flask

Pasting sample code that can be used as is to run ansible inside python flask app. This would be a very useful base implementation when devops need to control system over the web or someone tries to control systems over internet without cli. Prerequisites Install Python3 #PYTHON3 ( Assuming Centos7 or RHEL Flavor). Change accordingly for your env yum -y ...

Read More »

Part 3: Flask API Decorators and Helpers

This is the third of three posts about building a JSON API with Flask. Make sure you start with part 1 and part 2. In the first post, we used a custom base SQLAlchemy class to serialize and deserialize database models to and from JSON. The second post created a RESTful API listing and updating users. Now we’re ready for ...

Read More »

Part 2: Building a Flask RESTful API

This is the second of three posts about building a JSON API with Flask. Part 1 arrived yesterday and part 3 is arriving tomorrow. In the previous post we learned how to serialize SQLAlchemy models to/from JSON. Now let’s use that to build a RESTful JSON API with Flask. What is a RESTful API A RESTfu API is a website ...

Read More »

Part 1: SQLAlchemy Models to JSON

This is the first of three posts about building a JSON API with Flask. Part 2 and part 3 arrive tomorrow and the day after. I’ve seen a lot of questions on StackOverflow about how to turn SQLAlchemy models into JSON. When building a JSON API with Flask and SQLAlchemy, you end up writing a lot of boilerplate api code ...

Read More »

Fixtures in PyTest

1. Introduction PyTest is used for developing automation tests using python. It is a very powerful framework that can be utilized to write effective test automation scenarios in python. PyTest framework makes it easy to write small tests, yet scalable, to support complex applications and libraries. 2. PyTest fixtures The purpose of test fixtures is to provide an inbuilt baseline ...

Read More »