Python Programming Tips


How to Search in XML File Using Python and Lxml Library

Python is a powerful language when it comes to quick textual analysis of XML documents. Due to its simplicity and expressive power, it is possible to write short python scripts to do analysis on XML documents. In this article I provide a number of python scripts for processing and analysing content in XML documents. I […]

How to Connect to MySQL Database and Run Queries from Python

MySQL now provides support for pure python based access to mysql database. Use the python mysql connector in your program for accessing the mysql database. Run the following command in your machine’s command prompt to install the driver (this assumes you already have python3 installed), pip3 install mysql-connector-python If you get access denied error for […]

How to Run MongoDB Queries on Azure Cosmos DB Using Python

Azure Cosmos DB is a highly scalable and fully managed database service available on the Azure cloud platform. Using MongoDB API support, it is possible to store JSON documents in Azure Cosmos DB. If you are using Cosmos DB with MongoDB API support in your projects, sometimes you need quick Python scripts to analyse data. […]

How to Draw a Triangle in Python Turtle

Python has a simple pen drawing library called turtle. Using simple movement commands, we can draw shapes using the python turtle library. When teaching python to children, turtle is a good library to introduce to get children excited about the language and its features. The basic actions used in the following examples are, Draw a […]

How to Calculate SHA256 Hash of a File in Python

SHA256 is a secure hash algorithm which creates a fixed length one way string from any input data. The algorithm is designed in such a way that two different input will practically never lead to the same hash value. This property can be used to verify the integrity of the data. If data and hash […]