Latest Posts From Safa Mulani

Python Namedtuple

A sequence of immutable objects is a Tuple. Namedtuple enables the user to provide names to the elements in the Tuple. So, it provides the user with the option to access the elements either by index or by the designated name. Thus, it increases the readability of the code. Syntax: typename: It depicts the name […]

Python OrderedDict

OrderedDict is a subclass of the dictionary, which maintains the order in which the elements/items are added to it. OrderedDict preserves the order of insertion of the elements. A default dict does not save the order and results in the iteration in an arbitrary order. Initially, we need to import the collections module to use the […]

Python inspect module

Python’s inspect module provides the introspection of live objects and the source code of the same. It also provides the introspection of the classes and functions used throughout the program. The inspect module provides the user to make use of functions/methods in it to fetch the source code for the same, extract and parse the […]

Python Pendulum Module

Python’s pendulum module enables date/time conversions and manipulations. It helps the user to work easily with date/time formats. This module enables and provides all the functionalities provided by the pytz module. Installation of pendulum module through the command-line: Importing pendulum module: Display the current time The now() method is used to display the current date-time […]

Python arrow module

Python arrow module enables date-time manipulations. It helps create instances and manipulate the timestamp accordingly. It shows a user-friendly approach to deal with the date-time conversions. Features: Arrow module is supported by Python 2.7 and higher versions. Time-zone aware Parses the string automatically Full level implementation Installing the arrow module: pip install arrow Access the […]

Python add elements to an Array

Python doesn’t have a specific data type to represent arrays. The following can be used to represent arrays in Python: By using lists By using the array module By using the NumPy module 1. Adding to an array using Lists If we are using List as an array, the following methods can be used to […]