Rajendra Dharmkar has Published 452 Articles

Explain Inheritance vs Instantiation for Python classes.

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 09-Sep-2023 23:14:33

10K+ Views

InheritanceBeing an Object Oriented language, Python supports inheritance, it even supports multiple inheritance. Classes can inherit from other classes. A class can inherit attributes and behaviour methods from another class, called the superclass. A class which inherits from a superclass is called a subclass, also called heir class or child ... Read More

How to return an object from a function in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 09-Sep-2023 23:08:13

13K+ Views

The return statement makes a Python function to exit and hand back a value to its caller. The objective of functions in general is to take in inputs and return something. A return statement, once executed, immediately halts execution of a function, even if it is not the last statement ... Read More

How to get the return value from a function in a class in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 09-Sep-2023 23:05:46

12K+ Views

The following code shows how to get return value from a function in a Python class.Exampleclass Score():     def __init__(self):         self.score = 0         self.num_enemies = 5         self.num_lives = 3     def setScore(self, num):     ... Read More

How do we do a file upload using Python CGI Programming?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 09-Sep-2023 23:04:18

2K+ Views

To upload a file, the HTML form must have the enctype attribute set to multipart/form-data. The input tag with the file type creates a "Browse" button.Example        File:         OutputThe result of this code is the following form −File: Choose file UploadHere ... Read More

How to match non-word characters in Python using Regular Expression?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-Sep-2023 14:02:01

1K+ Views

The regular expressions module in Python provides a powerful tool for pattern matching in strings in Python. Regular expressions, also known as regex, make it possible for us to search, extract, and manipulate text based on specified patterns. One routine and common task in text processing is to identify non−word ... Read More

How do I do a case-insensitive string comparison in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-Sep-2023 13:58:17

1K+ Views

Have you ever encountered a situation where you needed to compare strings in Python but wanted to ignore the differences in letter casing? Worry not, for Python provides straightforward solutions to achieve case−insensitive string comparisons. In this comprehensive guide, we will explore five different code examples, each showcasing a unique ... Read More

How can I match the start and end in Python's regex?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-Sep-2023 13:51:19

623 Views

Have you ever come across situations where you had to determine if a string starts or ends with a particular pattern in Python? If so, you don’t need to worry, for Python's regular expressions provide a solution in such cases. With the power of regex, you can easily check whether ... Read More

How to match a word in python using Regular Expression?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-Sep-2023 13:40:19

2K+ Views

Mastering regular expressions and their ‘re’ module opens up a world of powerful text−processing possibilities in Python. Regular expressions, often called regex, make it possible for us to identify, search for, and manipulate specific patterns within strings. One common task that we often come across in our work is matching ... Read More

How to get the maximum file name length limit using Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-Sep-2023 13:25:24

1K+ Views

In the ever−evolving world of software development, understanding and being aware of the limitations of various file systems and operating systems is very critical. One such limitation that developers often encounter in their work is the maximum file name length limit. Various file systems and platforms have varying restrictions on ... Read More

How regular expression alternatives work in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 08-Sep-2023 13:20:56

730 Views

Python's built−in module 're' provides a powerful tool for working with text data, and regular expressions (regex) are a crucial part of it. However, sometimes you might need to use alternative methods to perform text manipulation tasks that don't involve regex. In this article, we'll explore five code examples that ... Read More

Previous 1 ... 3 4 5 6 7 ... 46 Next
Advertisements