Cover image for BairesDev
Logo

BairesDev

Actieve werkgever

BairesDev

Een sollicitatiegesprek toevoegen

Sollicitatievraag

Sollicitatiegesprek voor de functie Data Scientist With Python

-

BairesDev

What are magic methods in Python and what are they used for?

Antwoord op sollicitatievraag

1 Antwoord

0

These are special methods surrounded by double underscores, such as __init__, __repr__, __str___ __setitem__, __getitem__, __enter__, __exit__, __add__, __mult__, __next__ and so on... The interpreter invokes them in certain situations, such as when creating an object, converting it to string via built-in str() function. They are used for operator overloading, i.e. to make expressions such as a + b or a * b, or a[ i ] work for custom defined classes and not just for numbers, or arrays.

Anoniem op

Voeg antwoorden of opmerkingen toe

Meld u aan of registreer u om hier een opmerking over te maken.