Memory-Mapped (mmap) File Support in Python

What is a Memory-Mapped File in Python From Python’s official documentation, be sure to checkout Python’s mmap module: A memory-mapped file object behaves like both strings and like file objects. Unlike normal string objects, however, these are mutable. Basically, a memory-mapped (using Python’s mmap module) file object maps a normal file object into memory. This […]

Read More

Introductory Tutorial of Python’s SQLAlchemy

Python’s SQLAlchemy and Object-Relational Mapping A common task when programming any web service is the construction of a solid database backend. In the past, programmers would write raw SQL statements, pass them to the database engine and parse the returned results as a normal array of records. Nowadays, programmers can write Object-relational mapping (ORM) programs […]

Read More

Writing Simple Views for Your First Python Django Application

In the previous article Activate Admin Application for Your Python Django Website, we learned how to activate the built-in Admin Application from Django in your website. In this article, we are going to write simple views for your website. What is a view? In Django, a view is an endpoint that can be accessed by […]

Read More

Activate Admin Application for Your Python Django Website

In the previous article , we learned how to write two models Post and Comment for your Django application myblog. In this article, we are going to learn how to activate Django’s automatic admin site that provides a convenient interface for users or administrators of your website myblog to create, read, update and delete (CRUD) […]

Read More

Writing Models for Your First Python Django Application

The previous article Writing Your First Python Django Application is a step-by-step guide on how to write a simple Django application from scratch. In this article, you will learn how to write models for your new Django application. Software Architectural Patterns Before we dive into the code, let’s review two of the most popular server-side […]

Read More

Writing Your First Python Django Application

Create A Django Project The previous article Introduction to Python’s Django presented an overview of the Django Framework. In this article, we are going to write a simple Django application from scratch. The first step is to create a project using one of Django’s built-in commands django-admin.py. In a Virtualenv, type this command: [shell] django-admin.py […]

Read More

Introduction to Python’s Django

What is Web Development Web development is a broad term for any work that involves creating a web site for the Internet or an intranet. The end product of a web development project varies from simple sites composed of static web pages to complex applications that interact with databases and users. The list of tasks […]

Read More

How to Implement an ‘enum’ in Python

What is enum and why we need it? An enumerated type, a.k.a. enum, is a data type consisting of a set of named values called elements, members or enumerators of the type. These enumerated named values function as constants in the computing language. For example, a COLOR enum may include named values such as RED, […]

Read More

How to Get an Attribute from an Object in Python

Once we know how to check if an object has an attribute in Python, the next step is to get that attribute. In Python, besides the normal dot-style attribute access, there’s a built-in function, getattr, which is also very useful for accessing an attribute. Python’s Getattr The built-in function getattr(object, name[, default]) returns the value […]

Read More

How to Check if an Object has an Attribute in Python

Since everything in Python is an object and objects have attributes (fields and methods), it’s natural to write programs that can inspect what kind of attributes an object has. For example, a Python program could open a socket on the server and it accepts Python scripts sent over the network from a client machine. Upon […]

Read More