- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the advantages in using a Python class?
Classes are a mechanism to organize your code into generic, reusable peices of code. At their best they are reusable code snippets that will be used over and over again with little or no modification. The class concept was inspired by biological collections of features (attributes) and abilities (methods).
Functions are great to use when data is critical to the work being done. Classes are great when you need to represent a collection of attributes and methods that will be used repeatedly in other places.
Generally if you end up writing functions inside of functions you should consider writing a class instead. If you only have only one function in a class then better stick with just writing a function.
A good reason to move from functions to classes in your programming is to write classes using composition over inheritance.
- Related Articles
- What are the advantages of using the python pandas library?
- What are the advantages of belonging to a middle-class family?
- What are the advantages of using Cucumber?
- What are advantages of using JSP?
- What are the advantages of using Hijab in Modern Days?
- What are the advantages and disadvantages of using a solar cooker?
- What are the advantages of using C# ASP.NET WebAPI?
- What are the advantages of using LPG as fuel?
- What is a database and what are the advantages of using MySQL database?
- What are static methods in a Python class?
- What are the advantages of using fabrics made of polyester ?
- What are the advantages of using natural gas (or CNG) as a fuel?
- What are the advantages and disadvantages of using MySQL stored procedures?
- What are the advantages, disadvantages and restrictions of using MySQL triggers?
- What are the advantages of using CNG and LPG as fuels?
