THE PYTHON SHOW - MINI BYTES - EPISODE 1

THE PYTHON SHOW - MINI BYTES - EPISODE 1

ALEXA: Hi Python , how are you?

PYTHON: Hi Alexa , I am fine … Thanks for having me in the show.

ALEXA: I wanted to know three concepts : method accessor , method mutuator , operator overloading.

PYTHON: Ok , I can explain you . I wanted to make the session interactive . So tell me the literal meaning.. I mean English meaning of those three words as I am one among many languages having syntax in readable format…enough of flaunting myself ?? over to you..

ALEXA: Err… accessor means accessing something…mutuator, will google search… seems to be mutuation or modifying.. operator overloading refers to overloading put weight too much above it can handle…

PYTHON: Ok good , seems to be perfect synonyms … but I wonder Alexa a amazon product , google searching :P

ALEXA: Yeah … yeah … google search is everybody’s right , even amazon is one among everybody – so I can very well use them :p

PYTHON: Ok , enough of chit chatting lets come back to topic..

Method accessor : Access a object method – but does not change the value of the object.

 

No alt text provided for this image


Here value of x has not changed . The changed value is assigned to new object (y).

Now you would have guessed what could method mutuator do.

ALEXA: Yes .. so simple .. it modifies the current object

PYTHON: Good , then give me a snippet of the concept..

ALEXA: Err.. I can give … but still for the betterment of viewers , it makes sense to listen from the GURU.

PYTHON: Ok .. good handling of the request .. :p

No alt text provided for this image

The reverse method mutates the existing object, in this case the list that myList

refers to. Once called, a mutator method can’t be undone. The change or mutation

is permanent until mutated again by some other mutator method.

 Alexa: That’s nice to know .. ??

Python: Well , we will write a snippet utilizing both the concepts.

Alexa: Sure..

Python: Below is a snippet of code using both the concepts . Detailed code is as attached.

No alt text provided for this image

Result :

No alt text provided for this image

Alexa:  That sounds perfect … so are we moving to next concept of operator overloading?

Python: Yeah .. what are you feeling tired , digesting the concepts ?

Alexa:  No .. Not at all .. the concept is awesome…

Python: Cool … here operators like + , - , * are overloaded as per our convience.. When I say overload I modify the definition of them.

Alexa: Do you mean like mutuation..?

Python:  Yes , kind of but its local to that class and not global.

Alexa:  Can you please explain further?

Python: Yes , as below – we use self  which means that values assigned  by a object can be accessed only by those object.

No alt text provided for this image


No alt text provided for this image
No alt text provided for this image

Name of Dog1 can be accessed only by dog1 object and not by dog2 object…  Hope this is clear.

Alexa: Yes , now I understand the importance of self keyword.

Python: Good , coming back to overloading concept.

You can use the operator (+) or its method definition (__add__) as below to get output.

No alt text provided for this image

Now this method definition can be used in dog class to understand the behaviour.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Hope this concept is clear.

Alexa: Thanks for all the explanations. It was a nice having you in this show . Meet you in next episode with challenging queries.

Python : Bye.. Anytime ??

要查看或添加评论,请登录

Suraj S的更多文章

  • DEMYSITIFY UNS FOR IIOT

    DEMYSITIFY UNS FOR IIOT

    UNS stands for Unified Namespace . It refers to a specific architectural approach for data integration and…

  • TIME MANAGEMENT

    TIME MANAGEMENT

    For the past two years, I've adhered to these principles to maximize the value of my time, and I'd like to share some…

  • Explore Graph DBs to unlock Industrial IoT

    Explore Graph DBs to unlock Industrial IoT

    Unleashing the Power of Connections: Why Graph Databases Are a Game Changer In today's world of interconnected data…

    2 条评论
  • STRATEGIES TO DELIVER A SOFTWARE PRODUCT FASTER

    STRATEGIES TO DELIVER A SOFTWARE PRODUCT FASTER

    I have been coding and solving few problem statements for a pretty long time and follow this as my thumb rule Break…

    1 条评论
  • ASYNC PROGRAMMING

    ASYNC PROGRAMMING

    ?? Unlocking Efficiency: The Power of Asynchronous Programming ?? In the fast-paced world of software development…

  • Send automated Whatsapp messages

    Send automated Whatsapp messages

    On new year eve , I quickly wrote 2-3 lines of python code to send new year wishes to my friends and family exactly at…

  • What is MetaData Management in IoT and why is it important?

    What is MetaData Management in IoT and why is it important?

    Success of any IoT project lies in the way it is architect ed. A good architecture helps any IoT use-case aka project…

    2 条评论
  • What is Edge Computing in IoT and why is it required?

    What is Edge Computing in IoT and why is it required?

    Edge Computing : Making analysis of data nearest to the spot where it was generated to take quicker action. In the…

    2 条评论
  • Banana Kick in Football

    Banana Kick in Football

    Topic : Banana Kick seen in Football Scientific Theory Involved : Magnum effect and Newton Third Law We would have read…

  • Reason to not build IoT architecture using traditional TCP/IP headers.

    Reason to not build IoT architecture using traditional TCP/IP headers.

    The architecture of the original Internet was created long before communicating with billions of very simple devices…

    1 条评论

社区洞察

其他会员也浏览了