Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80684

Re: [Python-Dev] Dinamically set __call__ method

References (8 earlier) <mailman.15584.1415476169.18130.python-list@python.org> <cc7jtiFubltU1@mid.individual.net> <CALwzidnE9ZeHV6nM74hKX58LhZ0ova5qB60-eWbw2gLTtk+O3Q@mail.gmail.com> <mailman.15726.1415806493.18130.python-list@python.org> <ccips8Fs5j8U1@mid.individual.net>
From Fabio Zadrozny <fabiofz@gmail.com>
Date 2014-11-13 11:38 -0200
Subject Re: [Python-Dev] Dinamically set __call__ method
Newsgroups comp.lang.python
Message-ID <mailman.15774.1415885965.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Nov 13, 2014 at 2:20 AM, Gregory Ewing <greg.ewing@canterbury.ac.nz>
wrote:

> Fabio Zadrozny wrote:
>
>> can someone from python-dev give some background of why that's the way it
>> is?
>>
>
> It's because, with new-style classes, a class is also an
> instance (of class "type" or a subclass thereof). So
> without that rule, it would be ambiguous whether a dunder
> method applied to instances of a class or to the class
> itself.
>
> > and if maybe it's something which python-dev would consider worth
>
>> changing in the future -- not sure how much could break because of that
>> though
>>
>
> Something fairly fundamental that would break is classs
> instantiation! You instantiate a class by calling it, so if
> a(x) were implemented as a.__call__(x), and class C had
> a __call__ method, then C() would invoke that method
> instead of instantiating C.
>
>
Hi Gregory,

Thanks for the explanation -- it still does seem a bit surprising from an
end-user point of view, but it does make more sense now :)

Best Regards,

Fabio

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-04 11:12 -0800
  Re: [Python-Dev] Dinamically set __call__ method John Ladasky <john_ladasky@sbcglobal.net> - 2014-11-06 12:21 -0800
    Re: [Python-Dev] Dinamically set __call__ method dieter <dieter@handshake.de> - 2014-11-07 07:59 +0100
    Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-07 04:58 -0800
    Re: [Python-Dev] Dinamically set __call__ method dieter <dieter@handshake.de> - 2014-11-08 07:50 +0100
    Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-08 11:49 -0800
      Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-09 11:31 +1300
        Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-08 19:27 -0800
          Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-10 00:38 +1300
            Re: [Python-Dev] Dinamically set __call__ method Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-10 00:14 +1100
            Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-09 12:16 -0800
        Re: [Python-Dev] Dinamically set __call__ method Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-11 00:43 -0700
        Re: [Python-Dev] Dinamically set __call__ method Fabio Zadrozny <fabiofz@gmail.com> - 2014-11-12 13:33 -0200
          Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-13 17:20 +1300
            Re: [Python-Dev] Dinamically set __call__ method Fabio Zadrozny <fabiofz@gmail.com> - 2014-11-13 11:38 -0200
        Re: [Python-Dev] Dinamically set __call__ method Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-12 11:58 -0700

csiph-web