Programming

DefaultDict in Python

defaultdict is a subclass of the built-in dict class. Its functionality is the same as that of dict class, expect it allows new key to be given a default value based on the type of dictionary being created. Syntax To create defaultdict, use below syntax collections.defaultdict([default_factory[, …]]) It returns a [...]

2020-09-16T15:39:16+05:30Categories: Programming|Tags: |

OrderedDict in Python

Ordered dictionaries are just like regular dictionaries but have some extra capabilities relating to ordering operations. Both ordered dictionary and the built-in dict can remember insertion order. Some differences from dict are: Regular dict is efficient at mapping operations, but tracking insertion order is secondary. OrderedDict in Python is efficient [...]

2020-09-16T13:54:06+05:30Categories: Programming|Tags: |

Namedtuple in Python

Standard tuple uses numerical indexes to access its members. Remembering index for each value can lead to errors, especially if the tuple has a lot of fields. A namedtuple in Python assigns names, as well as the numerical index, to each member. It allow for more readable, self-documenting code. They [...]

2020-09-16T12:57:14+05:30Categories: Programming|Tags: |

Lambda Function in Python

In Python, lambda keyword is used to declare an anonymous function, which is called as Lambda functions. An anonymous function refers to a function declared with no name. They behave in the same way as regular functions that are declared using the def keyword. Syntax Lambda function has following syntax [...]

2022-01-13T16:29:54+05:30Categories: Programming|Tags: |

Map and Filter function in Python

Map and Filter are paradigms of functional programming. They allow you to apply a function across a number of iterables. map() and filter() functions are built-in with Python, so require no importing. Map It applies function to every item of iterable. Syntax of map() is map(function, iterable, …) It return [...]

2020-09-15T13:17:16+05:30Categories: Programming|Tags: |

String Interpolation in Python

String interpolation is a process of injecting value into a placeholder in a string literal. It helps in dynamically formatting the output. A placeholder is a variable to which you can assign data/value later. Python supports following ways for string interpolation str.format()f-stringTemplate String str.format() Str.format() is used for positional formatting. [...]

2020-09-15T18:09:30+05:30Categories: Programming|Tags: |

Reading and Writing JSON in Python

Serialization is the process of converting an object into a special format (usually bytes) so that it can be transferred over a network or stored in a persistent storage. Deserialization is the reverse of serialization. It converts the special format returned by the serialization back to the Object with the [...]

2020-09-14T13:21:07+05:30Categories: Programming|Tags: |

Opening URLs in Python

Urllib module in Python is used to access, and interact with, websites using URL (Uniform Resource Locator). A URL(colloquially termed a web address) is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. Urilib has below modules for working with URL [...]

2020-09-11T12:00:00+05:30Categories: Programming|Tags: |

Parsing URL in Python

Urllib module in Python is used to access, and interact with, websites using URL (Uniform Resource Locator). A URL (colloquially termed a web address) is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. Urilib has below modules for [...]

2020-10-01T10:40:32+05:30Categories: Programming|Tags: |

Generate Universally Unique Identifiers in Python

Introduction A universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. UUID is also known as the term globally unique identifier (GUID). UUIDs are, for practical purposes, unique. Probability that a UUID will be duplicated is not zero, it is close enough to zero [...]

2020-09-10T13:17:40+05:30Categories: Programming|Tags: |
Go to Top