On Oct 15, 12:14 am, Ole Streicher wrote:
> Hi,
>
> I am curious when one should implement a "__call__()" and when a
> "__getitem__()" method.
>
> For example, I want to display functions and data in the same plot. For
> a function, the natural interface would to be called as "f(x)", while
> the n
Ole Streicher wrote:
> I am curious when one should implement a "__call__()" and when a
> "__getitem__()" method.
>
> For example, I want to display functions and data in the same plot.
Wait: The term 'function' is overloaded. In Python and programming in
general, a function is a piece of code wi
On Thu, Oct 15, 2009 at 12:14 AM, Ole Streicher wrote:
> Hi,
>
> I am curious when one should implement a "__call__()" and when a
> "__getitem__()" method.
>
> For example, I want to display functions and data in the same plot. For
> a function, the natural interface would to be called as "f(x)",
On Thu, Oct 15, 2009 at 5:14 PM, Ole Streicher wrote:
> So what is the reason that Python has separate __call__()/() and
> __getitem__()/[] interfaces and what is the rule to choose between them?
Hi,
This is very interesting, a thought that never occured to me before.
Usually, a function is a
On Thu, 15 Oct 2009 09:14:35 +0200, Ole Streicher wrote:
> So what is the reason that Python has separate __call__()/() and
> __getitem__()/[] interfaces and what is the rule to choose between them?
They are separate so you can implement both, or just one, or neither,
whichever makes the most se
Hi,
I am curious when one should implement a "__call__()" and when a
"__getitem__()" method.
For example, I want to display functions and data in the same plot. For
a function, the natural interface would to be called as "f(x)", while
the natural interface for data would be "f[x]". On the other