Category: Miscellenous

  •  Data Compression

    Python’s standard library has a rich collection of modules for data compression and archiving. One can select whichever is suitable for his job. There are following modules related to data compression − Sr.No. Module & Description 1 zlibCompression compatible with gzip. 2 gzipSupport for gzip files. 3 bz2Support for bz2 compression. 4 lzmaCompression using the…

  •  Performance Measurement

    A given problem may be solved by more than one alternative algorithms. Hence, we need to optimize the performance of the solution. Python’s timeit module is a useful tool to measure the performance of a Python application. The timit() function in this module measures execution time of your Python code. Syntax timeit.timeit(stmt, setup, timer, number) Parameters Example…

  • Output Formatting

    Output Formatting in Python Output formatting in Python is used to make your code more readable and your output more user-friendly. Whether you are displaying simple text strings, complex data structures, or creating reports, Python offers several ways for formatting output. These ways include using − Additionally, Python’s “textwrap” and “pprint” modules offer advanced functionalities…

  • Templating

    Templating in Python Templating in Python is a technique used in web development to dynamically generate static HTML pages using templates and data. In this tutorial, we will explore the basics of templating in Python, including installation, creating templates, and rendering templates with data, with a focus on the Jinja2 templating engine. String Templates in…

  • Serialization

    Serialization in Python Serialization refers to the process of converting an object into a format that can be easily stored, transmitted, or reconstructed later. In Python, this involves converting complex data structures, such as objects or dictionaries, into a byte stream. Why Do We Use Serialization? Serialization allows data to be easily saved to disk…

  • Weak References

    Python uses reference counting mechanism while implementing garbage collection policy. Whenever an object in the memory is referred, the count is incremented by one. On the other hand, when the reference is removed, the count is decremented by 1. If the garbage collector running in the background finds any object with count as 0, it…

  • Database Access

    Database Access in Python Database access in Python is used to interact with databases, allowing applications to store, retrieve, update, and manage data consistently. Various relational database management systems (RDBMS) are supported for these tasks, each requiring specific Python packages for connectivity − Data input and generated during execution of a program is stored in…

  • Regular Expressions

    A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expression are popularly known as regex or regexp. Usually, such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings,…

  • Recursion

    Recursion is a fundamental programming concept where a function calls itself in order to solve a problem. This technique breaks down a complex problem into smaller and more manageable sub-problems of the same type. In Python, recursion is implemented by defining a function that makes one or more calls to itself within its own body.…

  • Decorators

    A Decorator in Python is a function that receives another function as argument. The argument function is the one to be decorated by decorator. The behaviour of argument function is extended by the decorator without actually modifying it. In this chapter, we whall learn how to use Python decorator. Defining Function Decorator Function in Python is…