Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,827 members, 7,956,138 topics. Date: Monday, 23 September 2024 at 04:51 AM

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

Nairaland Forum / Science/Technology / Programming / How Do I Implement This In Python ?? (662 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)

CSS Is Not A Programming Language? / I Need A Programmer / Bootstrap Modal Not Working.

(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. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.