Python with statement and context managers

Introduction Welcome to a new code snippets post. Today, we are going to summarize the use of with statement and context managers in Python. In coding, a typical scenario is to acquire a resource, use it and finally release the resource. If an exception occurs, the program may not have a chance to free the

Difference between assertion and exception in Python

Introduction Software quality assurance is extremely important in software development. The purpose of testing is to uncover serious defects before pushing products to production. Testing should be part of team culture and every member should participate.Test engineers can do black box, integration and system level testing. on the other hand, developers write unit tests. Testing

Base64 encoding in Python

Introduction Today, we are going to talk about base64 encoding in Python. Understanding how characters are represented is very important to make sense of base64. For beginners, I highly recommend that you check the following article. It explains how Python handles Unicode and string data types. Let us get started… What is base64 encoding? Base64

Python read json file to dictionary

Introduction In this code snippet, we are going to demonstrate how to read JSON data from file into a Python dictionary data structure. String to JSON The function json.loads() can be used to load JSON data from string to dictionary. To load the data from file, we need to convert the file to string. Let

Converting a list of lists to json in Python

Introduction JSON (Java Script Object Notation) is one of the most popular text formats on the web due to its simplicity, lightweight and adoption. It is used to structure data exchange between web services. You may check the following article for implementing a simple web service using Python. JSON is a subset of the JavaScript

iOS real device test automation tutorial using Appium and Python

Appium for iOS In this post, we are going to explain the necessary steps required to implement a basic iOS simulator and real device based test automation using Appium and Python. I assume that the reader is familiar with the following... Mac OS basics iOS basics (ex. Xcode, singing certificates, etc) Appium automation framework Python

Python insert list into list at index

Introduction This is a frequently asked question in Python despite its simplicity. In the code snippets below, we will provide straightforward examples to demonstrate how to embed a list within another list at the beginning, middle and end. Let us start with the first case... Python insert list into list at beginning The list object