Operator Overloading and Polymorphism in Python

Operator Overloading and Polymorphism in Hindi – हालांकि पिछले Sections में हमने जितने भी तरह के Expressions देखे, उन सभी में हमने केवल Python के Built-In Operators को ही Discuss किया है। लेकिन C++ व C# की तरह ही हम Python में किसी भी Operator को Python Class अथवा C Extension Type के माध्‍यम से Overload कर सकते हैं।

Operator Overloading एक ऐसी प्रक्रिया है, जिसके माध्‍यम से हम किसी Built-In Operator को अपनी जरूरत के आधार पर दूसरा Meaning दे सकते हैं। परिणामस्‍वरूप समान Operator Different Type के Objects पर Different Operations Perform करने लायक स्थिति में आ जाता है।

उदाहरण के लिए Plus ( + ) Operator द्वारा हम दो Number Values को आपस में जोड़ सकते हैं। लेकिन यदि हमें दो Complex Numbers जैसे कि Coordinates(x, y) को आपस में जोड़ना हो, तो हम बिना Plus Operator को Overload किए हुए ऐसा नहीं कर सकते। लेकिन जब एक बार हम Complex Object को कैसे जोड़ना चाहिए, ये बात Plus Operator को Overload करके Python Operator को समझा देते हैं, तो उसके बाद हम Complex Object को भी Exactly उसी तरह से Plus Operator का प्रयोग करते हुए जोड़ सकते हैं, जिस तरह से दो Numbers को जोड़ते हैं।

Python में Operators को Overload करने का काम सामान्‍यत: Classes के माध्‍यम से किया जाता है, जो कि एक User Defined Data Type होता है। लेकिन Classes बारे में तब तक ठीक से नहीं समझा जा सकता, जब तक कि हम Python में Object Oriented Programming Concepts को Implement करने के बारे में विस्‍तृत Discussion न करें क्‍योंकि OOPS भी अपने आप में एक Complete Subject है, जिसे काफी विस्‍तार से Discuss किया जाना जरूरी है और इस पुस्‍तक में सम्‍पूर्ण Object Oriented Python समझाना सम्‍भव नहीं है।

फिर भी Python स्‍वयं अपने स्‍तर पर भी कुछ Operators को Automatically Overload करने में सक्षम है जो कि Python के विभिन्‍न Built-In Object Type के आधार पर Process होने वाले Objects कुछ Basic Operations को Different तरीके से Perform करने की सुविधा दे देता है।

उदाहरण के लिए Plus Operator को जब Numerical Values के साथ Use किया जाता है, तब ये दो संख्‍याओं का जोड़ करके Result Return देता है लेकिन जब हम इसी Plus Operator को किसी Sequence Object जैसे कि String या List Object पर Apply करते हैं, तो Result के रूप में ये Plus Operator उन दो Sequences को Concatenation के रूप में जोड़ Return कर देता है।

एक ही Plus Operator को जब दो अलग Type के Operand Objects के बीच Specify करते हैं, तो हमें Different Output प्राप्‍त होता है, इसी प्रक्रिया को Object Oriented Programming के अन्‍तर्गत Polymorphism के नाम से जाना जाता है जहां Operator स्‍वयं ये तय करता है कि उसे किस Type के Operands के साथ Use किया जा रहा है लेकिन ये Polymorphism भी Object Oriented Programming का Concept है और इसे यहां विस्‍तार से Discuss किया जाना Practically सम्‍भव नहीं है क्‍योंकि ये पुस्‍तक केवल Core Python से सम्‍बंधित Concepts पर ही आधारित है। (Operator Overloading and Polymorphism in Hindi)

Manual or Explicit Type Conversion – Type Casting
Working with Numbers - Python Variables

Python in Hindi - BccFalna.comये Article इस वेबसाईट पर Selling हेतु उपलब्‍ध EBook Python in Hindi से लिया गया है। इसलिए यदि ये Article आपके लिए उपयोगी है, तो निश्चित रूप से ये EBook भी आपके लिए काफी उपयोगी साबित होगी।

Python in Hindi | Page: 602 | Format: PDF

BUY NOW GET DEMO REVIEWS

MidRangeHub Finance Auto Loans Bank Business Health Insurance Insurance Investment Law Lif Insurance Loan Stocks how to endorse a check chase sapphire travel insurance chase sapphire travel delay when are property taxes due Tower Loans how to sell stocks on cash app Voided Check Examples Personal Finance Books Collateral Loans how to sell stocks on cashapp how do you sell your stocks on cash app how to sell stock on cash app joint account sofi joint account ally joint account capital one joint account best bank for joint account chase joint account cyber insurance coverage silverfort free cyber insurance coverage silverfort monjouro savings card Money6x Real Estate