coderz.py

Keep Coding Keep Cheering!

Logging Module in Python

What is Logging? Logging is a method of recording events that occur when software is run. Logging is essential for the development, debugging, and operation of software. If you don’t have a logging record and your programme crashes, there’s a slim chance you’ll find out what went wrong. And determining the cause will take a […]

January 22, 2023 | python | No comments

Python Shallow and Deep Copy

Assignment statements in Python do not copy objects; instead, they create bindings between a target and an object. When we use the = operator, it only creates a new variable that shares the original object’s reference. We can use Python’s copy module to make “true copies” or “clones” of these objects. Python copy Module: The copy module […]

January 21, 2023 | python | No comments

Garbage Collection in Python

In Python, garbage collection refers to the process of automatically freeing up memory that is no longer being used by the program. This is done by the Python interpreter’s built-in garbage collector, which periodically scans the program’s memory and identifies objects that are no longer being used by any part of the program. These objects […]

January 20, 2023 | python | No comments

Assert Statement in Python

What is Assertion? In any programming language, assertions are the debugging tools that aid in the efficient operation of the code. Assumptions are primarily statements that a programmer knows to be true or always wants to be true and include in code so that if they are false, the code cannot continue to run. Assert […]

January 19, 2023 | python | No comments

@property Decorator in Python

The @property decorator in Python is used to define a method as a “getter” for the boundaries of a class attribute. It allows you to define a method that is accessed like an attribute, without needing to invoke it like a method. Here’s an example: In this example, the @property decorator is used to define […]

January 17, 2023 | python | No comments

Python Decorators

In Python, a decorator is a special kind of function that modifies the behavior of another function. Decorators are often implemented as closures, which are nested functions that can remember and access variables from their containing function, even after the containing function has finished executing. But before diving deep into decorators let us understand some […]

January 17, 2023 | python | No comments

Python Closures

Before we can understand what a closure is, we must first understand nested functions and non-local variables. Nested functions in Python: In Python, a function can be defined inside another function, creating a nested function. A nested function has access to the variables and parameters of the containing function, known as the enclosing function. This […]

January 17, 2023 | python | No comments

Generators in Python

Generator Function: In Python, a generator is a function that allows you to create an iterator, an object that generates a sequence of values. A generator function is defined using the keyword yield, rather than return. When a generator function is called, it returns a generator object, which can be used to iterate over the […]

January 17, 2023 | python | No comments

yield Keyword in Python

The yield keyword in Python is used in the body of a function like a return statement, but when a function with a yield statement is called, it returns a generator object instead of a single value. The generator can then be iterated over to retrieve the values produced by the yield statement one at […]

January 13, 2023 | python | No comments

Iterable and Iterator in Python

What is an Iterable? In Python, an iterable is an object that can be looped over, such as a list, tuple, or string. An iterator is an object that represents a stream of data, and it can be used to traverse through all the elements of an iterable. The built-in function iter() can be used […]

January 12, 2023 | python | No comments

Advertisement