Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Articles - Page 975 of 1048
239 Views
Python object is belongs to the object oriented programming language. We previously have idea and knowledge regarding the python object. provides several built-in functions that help you inspect various aspects of objects. Some of these methods, including help(), type(), dir(), id(), hasattr(), getattr(), and callable(). Using the help() function If we want to inspect the python object we have a built function of python named help(). That provides documentation about an object, including its methods and attributes. Example In the following code, we imported the power function from the math module. Next we applied the inbuilt function help() on power ... Read More
390 Views
The class is a blueprint, which is used as the reference to create the object. This contains attributes and methods in a logical entity.Let’s understand the usage of the class in an object-oriented programming language through a real-time scenario. Consider a library. In a library, we will have different numbers of books. Now we want to track every book from the library. For a book, we will have different attributes like book name, ... Read More
247 Views
We are currently coding of python C methods are being used. The base of all the libraries such as Numpy, Opencv, pytorch etc are built with the C and C++ i.e. these libraries internally call the Compiled C code where code will be executed in the machine and the result will be return in python wrapper. Why are we using the C methods in python? The reason why we are using the C method in python is the performance. The python performance will be decreased because of the dynamic typing. It has to reduce the type of operands to ... Read More
219 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 is a logical entity that contains some attributes and methods. Python '__init__()' The Python __init__() function is one of the OOP's concepts. The __init__() is called automatically whenever the object is been created to a class. The __init__() function is also known as a constructor. Constructors are used to initialize ... Read More
322 Views
Django is one of the frameworks used along with python to create the web pages in an efficient manner. It is also called as the framework included with batteries why because by default the Django framework gives the admin interface and database interface like SQLite 3 etc. It also provides us the default readymade components namely user authentication handling like sign in, signup and sign out. It provides the management panel for our website, forms, uploading the files etc. Why are we using the Django framework? Django is known for its scalability and comprehensive documentation. This framework is used by ... Read More
2K+ Views
OOPs is abbreviated as object oriented programming language. It helps us to deal with the real time entities with inheritance, polymorphism, encapsulation etc. By using the oops concept we can make the code and functions work together in a better way. Group of objects is called a class. The class contains the blueprint, which takes as the reference to create the object. This contains attributes and methods in a logical entity. Now let’s see why we have to split the code into multiple classes. If we create the entire code in the single class, it will be easy to write ... Read More
1K+ Views
There are different modules or packages in the python classes. When we use their names as it is in the code it will be somewhat clumsy and not good to see. So, we need to organize the python classes in modules and packages. Modules are the group of functions, classes or any block of code kept in a single file. The file extension of the methods will be .py. If the python code is with 300-400 lines of code, then it can be made as a module for better understandability. The module name can be available as ... Read More
1K+ Views
Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of wrapping data and the methods that work on data within one unit. This restricts accessing variables and methods directly and can prevent the accidental modification of data. To prevent accidental change, an object’s variable can only be changed by the object’s method. Those types of variables are known as private variables. In Python, getters and setters are methods used to access and modify private attributes of a class. These methods are ... Read More
898 Views
To instantiate the python class, we need to get the class name first. This is achieved by following codedef get_class( kls ): parts = kls.split('.') module = ".".join(parts[:-1]) m = __import__( module ) for comp in parts[1:]: m = getattr(m, comp) return mm is the classWe can instantiate this class as followsa = m() b = m(arg1, arg2) # passing args to the constructor
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 called the base class or parent class. In other words, inheritance refers to defining a new class with little or no modification to an existing class. Following is the syntax of the inheritance - class A: #class A (base class) pass class ... Read More