Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,162,546 members, 7,850,873 topics. Date: Wednesday, 05 June 2024 at 10:17 AM

How Do I Implement This In Python ?? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How Do I Implement This In Python ?? (579 Views)

How Can I Implement Previous And Next Page In Handlebars / How Do I Implement A Contact Page In ASP.NET/C#? / Who Can Implement This On SPC4 *image Inside* (2) (3) (4)

(1) (Reply) (Go Down)

How Do I Implement This In Python ?? by shegzhkn: 1:53pm On Aug 04, 2020
Python is an object oriented programming language along side language like Java, C++, C#, etc

one of the concept of OOP is polymorphism allowing object to be created in different form.

Now here is the real deal, Java support Constructor overloading the same for C# but you have to be creative to do that in python say use of default value in the init method.

But i needed to create an object of a class in different form and using default value will not cut it or make it work the way i wanted it to.

So can I create another class with similar logic with slight discrepancies from the former and i am considering efficiency here.

Thanks
Re: How Do I Implement This In Python ?? by Shepherdd(m): 2:53pm On Aug 04, 2020
shegzhkn:
Python is an object oriented programming language along side language like Java, C++, C#, etc

one of the concept of OOP is polymorphism allowing object to be created in different form.

Now here is the real deal, Java support Constructor overloading the same for C# but you have to be creative to do that in python say use of default value in the init method.

But i needed to create an object of a class in different form and using default value will not cut it or make it work the way i wanted it to.

So can I create another class with similar logic with slight discrepancies from the former and i am considering efficiency here.

Thanks

Python supports polymorphism very well (almost), could you post a snippet of what you are trying to do in java or elaborate further.
Re: How Do I Implement This In Python ?? by shegzhkn: 3:02pm On Aug 04, 2020
Shepherdd:


Python supports polymorphism very well (almost), could you post a snippet of what you are trying to do in java or elaborate further.

How ?, elaborate.
Re: How Do I Implement This In Python ?? by Shepherdd(m): 3:17pm On Aug 04, 2020
shegzhkn:


How ?, elaborate.

Most of the time **kwargs will be sufficient, and if you need overloading based on compile time differentiation of objects, read about python single dispatch on Google.
Re: How Do I Implement This In Python ?? by shegzhkn: 3:56pm On Aug 04, 2020
Shepherdd:


Most of the time **kwargs will be sufficient, and if you need overloading based on compile time differentiation of objects, read about python single dispatch on Google.

Tried that my friend, thanks i appreciate your input.
Gracias
Re: How Do I Implement This In Python ?? by Shepherdd(m): 6:05pm On Aug 04, 2020
shegzhkn:


Tried that my friend, thanks i appreciate your input.
Gracias

Ok. This library could also be of help if you need something similar to Java's overloading. https://github.com/mrocklin/multipledispatch
Re: How Do I Implement This In Python ?? by shegzhkn: 11:03am On Aug 05, 2020
Shepherdd:


Ok. This library could also be of help if you need something similar to Java's overloading. https://github.com/mrocklin/multipledispatch

Thanks boss i really appreciate.

(1) (Reply)

Hiring An Ionic Framework Programmer / What Is The Difference Between A Developer, Programmer And A Coder? / How Opencart Mobile App Builder Can Help Your Ecommerce Business Grow

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.