__call__ or __init__ called here? Don't undestand which and why











up vote
0
down vote

favorite
1












Edit: this is unfortunately not answered in What is the difference between __init__ and __call__ in Python?





class OAuth2Bearer(requests.auth.AuthBase):

def __init__(self, api_key, access_token):
self._api_key = api_key
self._access_token = access_token

def __call__(self, r):
r.headers['Api-Key'] = self._api_key
r.headers['Authorization'] = "Bearer {}".format(self._access_token)
return r

#############

class AllegroAuthHandler(object):
def apply_auth(self):
return OAuth2Bearer(self._api_key, self.access_token) # what will happen here?


I read about __init__ and __call__, but I still don't undestand what is going on in this code



I don't understand:



1.) Which method will be called, __init__ or __call__



2.) If __init__, then __init__ doesn't return anything



3.) If __call__, then __call__ can't be called with two parameters



I think __init__ should be called, because we have X(), not x() from example below as in this answer:



x = X() # __init__ (constructor)
x() # __call__









share|improve this question
























  • Nice explanation here: stackoverflow.com/a/9663601/259889
    – Sid
    Nov 11 at 5:12










  • Possible duplicate of What is the difference between __init__ and __call__ in Python?
    – Severin Pappadeux
    Nov 11 at 5:12










  • @SeverinPappadeux Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • @Sid Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • You're right that __init__ doesn't return anything, but it's called on the new object, which is what gets returned when you call the class. So you could sort of imagine a return self and you'd have more or less the right idea.
    – Blckknght
    Nov 11 at 5:19















up vote
0
down vote

favorite
1












Edit: this is unfortunately not answered in What is the difference between __init__ and __call__ in Python?





class OAuth2Bearer(requests.auth.AuthBase):

def __init__(self, api_key, access_token):
self._api_key = api_key
self._access_token = access_token

def __call__(self, r):
r.headers['Api-Key'] = self._api_key
r.headers['Authorization'] = "Bearer {}".format(self._access_token)
return r

#############

class AllegroAuthHandler(object):
def apply_auth(self):
return OAuth2Bearer(self._api_key, self.access_token) # what will happen here?


I read about __init__ and __call__, but I still don't undestand what is going on in this code



I don't understand:



1.) Which method will be called, __init__ or __call__



2.) If __init__, then __init__ doesn't return anything



3.) If __call__, then __call__ can't be called with two parameters



I think __init__ should be called, because we have X(), not x() from example below as in this answer:



x = X() # __init__ (constructor)
x() # __call__









share|improve this question
























  • Nice explanation here: stackoverflow.com/a/9663601/259889
    – Sid
    Nov 11 at 5:12










  • Possible duplicate of What is the difference between __init__ and __call__ in Python?
    – Severin Pappadeux
    Nov 11 at 5:12










  • @SeverinPappadeux Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • @Sid Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • You're right that __init__ doesn't return anything, but it's called on the new object, which is what gets returned when you call the class. So you could sort of imagine a return self and you'd have more or less the right idea.
    – Blckknght
    Nov 11 at 5:19













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





Edit: this is unfortunately not answered in What is the difference between __init__ and __call__ in Python?





class OAuth2Bearer(requests.auth.AuthBase):

def __init__(self, api_key, access_token):
self._api_key = api_key
self._access_token = access_token

def __call__(self, r):
r.headers['Api-Key'] = self._api_key
r.headers['Authorization'] = "Bearer {}".format(self._access_token)
return r

#############

class AllegroAuthHandler(object):
def apply_auth(self):
return OAuth2Bearer(self._api_key, self.access_token) # what will happen here?


I read about __init__ and __call__, but I still don't undestand what is going on in this code



I don't understand:



1.) Which method will be called, __init__ or __call__



2.) If __init__, then __init__ doesn't return anything



3.) If __call__, then __call__ can't be called with two parameters



I think __init__ should be called, because we have X(), not x() from example below as in this answer:



x = X() # __init__ (constructor)
x() # __call__









share|improve this question















Edit: this is unfortunately not answered in What is the difference between __init__ and __call__ in Python?





class OAuth2Bearer(requests.auth.AuthBase):

def __init__(self, api_key, access_token):
self._api_key = api_key
self._access_token = access_token

def __call__(self, r):
r.headers['Api-Key'] = self._api_key
r.headers['Authorization'] = "Bearer {}".format(self._access_token)
return r

#############

class AllegroAuthHandler(object):
def apply_auth(self):
return OAuth2Bearer(self._api_key, self.access_token) # what will happen here?


I read about __init__ and __call__, but I still don't undestand what is going on in this code



I don't understand:



1.) Which method will be called, __init__ or __call__



2.) If __init__, then __init__ doesn't return anything



3.) If __call__, then __call__ can't be called with two parameters



I think __init__ should be called, because we have X(), not x() from example below as in this answer:



x = X() # __init__ (constructor)
x() # __call__






python class constructor call init






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 5:14

























asked Nov 11 at 5:10









qewghbjhb

239




239












  • Nice explanation here: stackoverflow.com/a/9663601/259889
    – Sid
    Nov 11 at 5:12










  • Possible duplicate of What is the difference between __init__ and __call__ in Python?
    – Severin Pappadeux
    Nov 11 at 5:12










  • @SeverinPappadeux Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • @Sid Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • You're right that __init__ doesn't return anything, but it's called on the new object, which is what gets returned when you call the class. So you could sort of imagine a return self and you'd have more or less the right idea.
    – Blckknght
    Nov 11 at 5:19


















  • Nice explanation here: stackoverflow.com/a/9663601/259889
    – Sid
    Nov 11 at 5:12










  • Possible duplicate of What is the difference between __init__ and __call__ in Python?
    – Severin Pappadeux
    Nov 11 at 5:12










  • @SeverinPappadeux Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • @Sid Unfortunately this is not explaining questions 2 and 3 :-(
    – qewghbjhb
    Nov 11 at 5:18










  • You're right that __init__ doesn't return anything, but it's called on the new object, which is what gets returned when you call the class. So you could sort of imagine a return self and you'd have more or less the right idea.
    – Blckknght
    Nov 11 at 5:19
















Nice explanation here: stackoverflow.com/a/9663601/259889
– Sid
Nov 11 at 5:12




Nice explanation here: stackoverflow.com/a/9663601/259889
– Sid
Nov 11 at 5:12












Possible duplicate of What is the difference between __init__ and __call__ in Python?
– Severin Pappadeux
Nov 11 at 5:12




Possible duplicate of What is the difference between __init__ and __call__ in Python?
– Severin Pappadeux
Nov 11 at 5:12












@SeverinPappadeux Unfortunately this is not explaining questions 2 and 3 :-(
– qewghbjhb
Nov 11 at 5:18




@SeverinPappadeux Unfortunately this is not explaining questions 2 and 3 :-(
– qewghbjhb
Nov 11 at 5:18












@Sid Unfortunately this is not explaining questions 2 and 3 :-(
– qewghbjhb
Nov 11 at 5:18




@Sid Unfortunately this is not explaining questions 2 and 3 :-(
– qewghbjhb
Nov 11 at 5:18












You're right that __init__ doesn't return anything, but it's called on the new object, which is what gets returned when you call the class. So you could sort of imagine a return self and you'd have more or less the right idea.
– Blckknght
Nov 11 at 5:19




You're right that __init__ doesn't return anything, but it's called on the new object, which is what gets returned when you call the class. So you could sort of imagine a return self and you'd have more or less the right idea.
– Blckknght
Nov 11 at 5:19












3 Answers
3






active

oldest

votes

















up vote
2
down vote



accepted










I believe this is what you're looking for.



The behaviour of calling an object in Python is governed by its type's __call__, so this:



OAuth2Bearer(args)


Is actually this:



type(OAuth2Bearer).__call__(OAuth2Bearer, args)


What is the type of OAuth2Bearer, also called its "metaclass"? If not type, the default, then a subclass of type (this is strictly enforced by Python). From the link above:




If we ignore error checking for a minute, then for regular class instantiation this is roughly equivalent to:




def __call__(obj_type, *args, **kwargs):
obj = obj_type.__new__(*args, **kwargs)
if obj is not None and issubclass(obj, obj_type):
obj.__init__(*args, **kwargs)
return obj


So the result of the call is the result of object.__new__ after passed to object.__init__. object.__new__ basically just allocates space for a new object and is the only way of doing so AFAIK. To call OAuth2Bearer.__call__, you would have to call the instance:



OAuth2Bearer(init_args)(call_args)





share|improve this answer



















  • 1




    Thank you, it is much clearer now!
    – qewghbjhb
    Nov 12 at 11:41










  • Please mark this as the answer if it pleases you :)
    – roeen30
    Nov 13 at 13:08










  • Great answer! Very helpful.
    – Dr_bitz
    Nov 13 at 13:58


















up vote
0
down vote













I'd say it's neither here.



The part of code that's causing confusion is



OAuth2Bearer(self._api_key, self.access_token)


You need to know one thing: While OAuth2Bearer is the name of a class, it's also an object of class type (a built-in class). So when you write the above line, what's actually called is



type.__call__()


This can be easily verified if you try this code:



print(repr(OAuth2Bearer.__call__))


it will return something like this:



<method-wrapper '__call__' of type object at 0x12345678>


What type.__call__ does and returns is well covered in other questions: It calls OAuth2Bearer.__new__() to create an object, and then initialize that object with obj.__init__(), and returns that object.



You can think of the content of OAuth2Bearer(self._api_key, self.access_token) like this (pseudo-code for illustration purposes)



OAuth2Bearer(self._api_key, self.access_token):
obj = OAuth2Bearer.__new__(OAuth2Bearer, self._api_key, self.access_token)
obj.__init__()
return obj





share|improve this answer





















  • Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
    – qewghbjhb
    Nov 12 at 11:33












  • @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
    – iBug
    Nov 12 at 15:05




















up vote
0
down vote













__init__() is called when used with Class



__call__() is called when used with object of Class






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246013%2fcall-or-init-called-here-dont-undestand-which-and-why%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    I believe this is what you're looking for.



    The behaviour of calling an object in Python is governed by its type's __call__, so this:



    OAuth2Bearer(args)


    Is actually this:



    type(OAuth2Bearer).__call__(OAuth2Bearer, args)


    What is the type of OAuth2Bearer, also called its "metaclass"? If not type, the default, then a subclass of type (this is strictly enforced by Python). From the link above:




    If we ignore error checking for a minute, then for regular class instantiation this is roughly equivalent to:




    def __call__(obj_type, *args, **kwargs):
    obj = obj_type.__new__(*args, **kwargs)
    if obj is not None and issubclass(obj, obj_type):
    obj.__init__(*args, **kwargs)
    return obj


    So the result of the call is the result of object.__new__ after passed to object.__init__. object.__new__ basically just allocates space for a new object and is the only way of doing so AFAIK. To call OAuth2Bearer.__call__, you would have to call the instance:



    OAuth2Bearer(init_args)(call_args)





    share|improve this answer



















    • 1




      Thank you, it is much clearer now!
      – qewghbjhb
      Nov 12 at 11:41










    • Please mark this as the answer if it pleases you :)
      – roeen30
      Nov 13 at 13:08










    • Great answer! Very helpful.
      – Dr_bitz
      Nov 13 at 13:58















    up vote
    2
    down vote



    accepted










    I believe this is what you're looking for.



    The behaviour of calling an object in Python is governed by its type's __call__, so this:



    OAuth2Bearer(args)


    Is actually this:



    type(OAuth2Bearer).__call__(OAuth2Bearer, args)


    What is the type of OAuth2Bearer, also called its "metaclass"? If not type, the default, then a subclass of type (this is strictly enforced by Python). From the link above:




    If we ignore error checking for a minute, then for regular class instantiation this is roughly equivalent to:




    def __call__(obj_type, *args, **kwargs):
    obj = obj_type.__new__(*args, **kwargs)
    if obj is not None and issubclass(obj, obj_type):
    obj.__init__(*args, **kwargs)
    return obj


    So the result of the call is the result of object.__new__ after passed to object.__init__. object.__new__ basically just allocates space for a new object and is the only way of doing so AFAIK. To call OAuth2Bearer.__call__, you would have to call the instance:



    OAuth2Bearer(init_args)(call_args)





    share|improve this answer



















    • 1




      Thank you, it is much clearer now!
      – qewghbjhb
      Nov 12 at 11:41










    • Please mark this as the answer if it pleases you :)
      – roeen30
      Nov 13 at 13:08










    • Great answer! Very helpful.
      – Dr_bitz
      Nov 13 at 13:58













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    I believe this is what you're looking for.



    The behaviour of calling an object in Python is governed by its type's __call__, so this:



    OAuth2Bearer(args)


    Is actually this:



    type(OAuth2Bearer).__call__(OAuth2Bearer, args)


    What is the type of OAuth2Bearer, also called its "metaclass"? If not type, the default, then a subclass of type (this is strictly enforced by Python). From the link above:




    If we ignore error checking for a minute, then for regular class instantiation this is roughly equivalent to:




    def __call__(obj_type, *args, **kwargs):
    obj = obj_type.__new__(*args, **kwargs)
    if obj is not None and issubclass(obj, obj_type):
    obj.__init__(*args, **kwargs)
    return obj


    So the result of the call is the result of object.__new__ after passed to object.__init__. object.__new__ basically just allocates space for a new object and is the only way of doing so AFAIK. To call OAuth2Bearer.__call__, you would have to call the instance:



    OAuth2Bearer(init_args)(call_args)





    share|improve this answer














    I believe this is what you're looking for.



    The behaviour of calling an object in Python is governed by its type's __call__, so this:



    OAuth2Bearer(args)


    Is actually this:



    type(OAuth2Bearer).__call__(OAuth2Bearer, args)


    What is the type of OAuth2Bearer, also called its "metaclass"? If not type, the default, then a subclass of type (this is strictly enforced by Python). From the link above:




    If we ignore error checking for a minute, then for regular class instantiation this is roughly equivalent to:




    def __call__(obj_type, *args, **kwargs):
    obj = obj_type.__new__(*args, **kwargs)
    if obj is not None and issubclass(obj, obj_type):
    obj.__init__(*args, **kwargs)
    return obj


    So the result of the call is the result of object.__new__ after passed to object.__init__. object.__new__ basically just allocates space for a new object and is the only way of doing so AFAIK. To call OAuth2Bearer.__call__, you would have to call the instance:



    OAuth2Bearer(init_args)(call_args)






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 11 at 9:31

























    answered Nov 11 at 9:25









    roeen30

    43629




    43629








    • 1




      Thank you, it is much clearer now!
      – qewghbjhb
      Nov 12 at 11:41










    • Please mark this as the answer if it pleases you :)
      – roeen30
      Nov 13 at 13:08










    • Great answer! Very helpful.
      – Dr_bitz
      Nov 13 at 13:58














    • 1




      Thank you, it is much clearer now!
      – qewghbjhb
      Nov 12 at 11:41










    • Please mark this as the answer if it pleases you :)
      – roeen30
      Nov 13 at 13:08










    • Great answer! Very helpful.
      – Dr_bitz
      Nov 13 at 13:58








    1




    1




    Thank you, it is much clearer now!
    – qewghbjhb
    Nov 12 at 11:41




    Thank you, it is much clearer now!
    – qewghbjhb
    Nov 12 at 11:41












    Please mark this as the answer if it pleases you :)
    – roeen30
    Nov 13 at 13:08




    Please mark this as the answer if it pleases you :)
    – roeen30
    Nov 13 at 13:08












    Great answer! Very helpful.
    – Dr_bitz
    Nov 13 at 13:58




    Great answer! Very helpful.
    – Dr_bitz
    Nov 13 at 13:58












    up vote
    0
    down vote













    I'd say it's neither here.



    The part of code that's causing confusion is



    OAuth2Bearer(self._api_key, self.access_token)


    You need to know one thing: While OAuth2Bearer is the name of a class, it's also an object of class type (a built-in class). So when you write the above line, what's actually called is



    type.__call__()


    This can be easily verified if you try this code:



    print(repr(OAuth2Bearer.__call__))


    it will return something like this:



    <method-wrapper '__call__' of type object at 0x12345678>


    What type.__call__ does and returns is well covered in other questions: It calls OAuth2Bearer.__new__() to create an object, and then initialize that object with obj.__init__(), and returns that object.



    You can think of the content of OAuth2Bearer(self._api_key, self.access_token) like this (pseudo-code for illustration purposes)



    OAuth2Bearer(self._api_key, self.access_token):
    obj = OAuth2Bearer.__new__(OAuth2Bearer, self._api_key, self.access_token)
    obj.__init__()
    return obj





    share|improve this answer





















    • Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
      – qewghbjhb
      Nov 12 at 11:33












    • @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
      – iBug
      Nov 12 at 15:05

















    up vote
    0
    down vote













    I'd say it's neither here.



    The part of code that's causing confusion is



    OAuth2Bearer(self._api_key, self.access_token)


    You need to know one thing: While OAuth2Bearer is the name of a class, it's also an object of class type (a built-in class). So when you write the above line, what's actually called is



    type.__call__()


    This can be easily verified if you try this code:



    print(repr(OAuth2Bearer.__call__))


    it will return something like this:



    <method-wrapper '__call__' of type object at 0x12345678>


    What type.__call__ does and returns is well covered in other questions: It calls OAuth2Bearer.__new__() to create an object, and then initialize that object with obj.__init__(), and returns that object.



    You can think of the content of OAuth2Bearer(self._api_key, self.access_token) like this (pseudo-code for illustration purposes)



    OAuth2Bearer(self._api_key, self.access_token):
    obj = OAuth2Bearer.__new__(OAuth2Bearer, self._api_key, self.access_token)
    obj.__init__()
    return obj





    share|improve this answer





















    • Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
      – qewghbjhb
      Nov 12 at 11:33












    • @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
      – iBug
      Nov 12 at 15:05















    up vote
    0
    down vote










    up vote
    0
    down vote









    I'd say it's neither here.



    The part of code that's causing confusion is



    OAuth2Bearer(self._api_key, self.access_token)


    You need to know one thing: While OAuth2Bearer is the name of a class, it's also an object of class type (a built-in class). So when you write the above line, what's actually called is



    type.__call__()


    This can be easily verified if you try this code:



    print(repr(OAuth2Bearer.__call__))


    it will return something like this:



    <method-wrapper '__call__' of type object at 0x12345678>


    What type.__call__ does and returns is well covered in other questions: It calls OAuth2Bearer.__new__() to create an object, and then initialize that object with obj.__init__(), and returns that object.



    You can think of the content of OAuth2Bearer(self._api_key, self.access_token) like this (pseudo-code for illustration purposes)



    OAuth2Bearer(self._api_key, self.access_token):
    obj = OAuth2Bearer.__new__(OAuth2Bearer, self._api_key, self.access_token)
    obj.__init__()
    return obj





    share|improve this answer












    I'd say it's neither here.



    The part of code that's causing confusion is



    OAuth2Bearer(self._api_key, self.access_token)


    You need to know one thing: While OAuth2Bearer is the name of a class, it's also an object of class type (a built-in class). So when you write the above line, what's actually called is



    type.__call__()


    This can be easily verified if you try this code:



    print(repr(OAuth2Bearer.__call__))


    it will return something like this:



    <method-wrapper '__call__' of type object at 0x12345678>


    What type.__call__ does and returns is well covered in other questions: It calls OAuth2Bearer.__new__() to create an object, and then initialize that object with obj.__init__(), and returns that object.



    You can think of the content of OAuth2Bearer(self._api_key, self.access_token) like this (pseudo-code for illustration purposes)



    OAuth2Bearer(self._api_key, self.access_token):
    obj = OAuth2Bearer.__new__(OAuth2Bearer, self._api_key, self.access_token)
    obj.__init__()
    return obj






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 11 at 5:20









    iBug

    16.4k53359




    16.4k53359












    • Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
      – qewghbjhb
      Nov 12 at 11:33












    • @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
      – iBug
      Nov 12 at 15:05




















    • Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
      – qewghbjhb
      Nov 12 at 11:33












    • @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
      – iBug
      Nov 12 at 15:05


















    Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
    – qewghbjhb
    Nov 12 at 11:33






    Do I undestand correctly that return OAuth2Bearer(init_args) would be return new OAuth2Bearer(init_args) in C# ?
    – qewghbjhb
    Nov 12 at 11:33














    @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
    – iBug
    Nov 12 at 15:05






    @qewghbjhb I don't know C# but it appears like you're right (I read Java and they're similar so this is a guess).
    – iBug
    Nov 12 at 15:05












    up vote
    0
    down vote













    __init__() is called when used with Class



    __call__() is called when used with object of Class






    share|improve this answer



























      up vote
      0
      down vote













      __init__() is called when used with Class



      __call__() is called when used with object of Class






      share|improve this answer

























        up vote
        0
        down vote










        up vote
        0
        down vote









        __init__() is called when used with Class



        __call__() is called when used with object of Class






        share|improve this answer














        __init__() is called when used with Class



        __call__() is called when used with object of Class







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 11 at 5:50









        eyllanesc

        69k93052




        69k93052










        answered Nov 11 at 5:49









        rajamohan reddy

        212




        212






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246013%2fcall-or-init-called-here-dont-undestand-which-and-why%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python