Akshitha Mote has Published 55 Articles

When are python classes and class attributes garbage collected?

Akshitha Mote

Akshitha Mote

Updated on 29-May-2025 14:10:07

442 Views

In Python, a class is a collection of objects. It is the blueprint from which objects are being created. It is a logical entity that contains some attributes and methods. Following is an example of a Python class - class Tutorialspoint: print("Welcome to Tutorialspoint.") ... Read More

What is best way to check if a list is empty in Python?

Akshitha Mote

Akshitha Mote

Updated on 29-May-2025 14:05:10

451 Views

A List in Python is a mutable sequence of elements separated by commas ", ". It is represented by square braces "[ ]".An empty list contains no elements, meaning its length is 0. It is indicated by the square braces with no elements in it.In this article, we will explore various methods ... Read More

Do you think garbage collector can track all the Python objects?

Akshitha Mote

Akshitha Mote

Updated on 29-May-2025 13:07:10

185 Views

The garbage collector doesn't track (and collect) all the objects; it can only track objects that are unreachable (have a reference count of zero), and the objects that are involved in circular references. What is a garbage collector? The garbage collector is an automatic (implicit) process that handles memory allocation ... Read More

How do I declare a global variable in Python class?

Akshitha Mote

Akshitha Mote

Updated on 30-Apr-2025 17:50:03

11K+ Views

A global variable is a variable with global scope, meaning it is visible and accessible throughout the program. The collection of all global variables is known as the global environment or global scope of the program. The variables declared outside the ... Read More

How to convert a string to a Python class object?

Akshitha Mote

Akshitha Mote

Updated on 30-Apr-2025 17:25:37

13K+ Views

Let's understand the title: converting a string to a Python class means accessing a Python class using its name stored as a string, allowing dynamic creation of objects at runtime. In this article, we will discuss different ways to convert a string to a Python class object. Using globals() Function ... Read More

Explain Inheritance vs Instantiation for Python classes.

Akshitha Mote

Akshitha Mote

Updated on 30-Apr-2025 16:33:09

11K+ Views

In Python, inheritance is the capability of one class to derive or inherit the properties from another class. The class that derives properties is called the derived class or child class, and the class from which the properties are being derived is ... Read More

What are different types of quotes in Python?

Akshitha Mote

Akshitha Mote

Updated on 30-Apr-2025 16:19:16

7K+ Views

In Python, strings can be defined using single quotes ('), double quotes ("), or triple quotes (''' or """). For example, 'Hello' is a valid string. There are different types of quotes in Python. Each quotation is used in different scenarios as per the requirement. The following are the different ... Read More

What is the difference between dict.items() and dict.iteritems() in Python?

Akshitha Mote

Akshitha Mote

Updated on 30-Apr-2025 14:24:04

470 Views

In Python, the dict.items() and dict.iteritems() methods are used to return a dictionary. The only difference is that the dict.items() returns the keys and value pairs in the form of a list of tuple pairs, whereas the dict.iteritems() returns an iterator over the dictionary’s (key, value) tuple pairs. The dict.items() ... Read More

What is __init__.py in Python?

Akshitha Mote

Akshitha Mote

Updated on 29-Apr-2025 18:58:46

2K+ Views

In Python, the __init__.py is a special file in python packages. It is used to indicate that how a directory should be treated. When Python encounters a directory during an import, first it looks for the __init__.py file to determine how to initialize the package and what code should be ... Read More

Do you think declarations within Python class are equivalent to those within __init__ method?

Akshitha Mote

Akshitha Mote

Updated on 24-Apr-2025 19:11:45

207 Views

In Python, the declarations within a class are not equivalent to those within the __init__() method. Let's discuss the class and __init__() method. A class is a collection of objects. It contains the blueprints or the prototype from which the objects are being created. It ... Read More

Advertisements