On Fri, Sep 30, 2011 at 09:50:42PM -0700, Fletcher Johnson wrote:
> Is it possible to overload operators for a function?
>
> For instance I would like to do something roughly like...
>
> def func_maker():
> def func(): pass
>
> def __eq__(other):
> if other == "check": return True
>
On Fri, Sep 30, 2011 at 9:50 PM, Fletcher Johnson wrote:
> Is it possible to overload operators for a function?
>
> For instance I would like to do something roughly like...
>
> def func_maker():
> def func(): pass
>
> def __eq__(other):
> if other == "check": return True
> return False
>
Is it possible to overload operators for a function?
For instance I would like to do something roughly like...
def func_maker():
def func(): pass
def __eq__(other):
if other == "check": return True
return False
func.__eq__ = __eq__
return func
newfunc = func_maker()
newfunc ==
On Thu, Oct 16, 2008 at 10:54 PM, Lie Ryan <[EMAIL PROTECTED]> wrote:
> On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Something that is more pythonic is something that doesn't use
> multimethods. It's just an elaborated way to do type checking. In python,
> you usually avoid type checking a
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I defined.
>
>
> What is the best way to do this? Shall I use a lot of "if...elif"
> statements inside the ov
Thanks for the suggestion. I think I'm gonna try the multimethods way,
that I didn't know about it.
--
http://mail.python.org/mailman/listinfo/python-list
On 15 Okt., 14:34, Mr.SpOOn <[EMAIL PROTECTED]> wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I
> defined.
>
> Sometimes I need a different behavior of the operator depending on the
> argument. For exam
On Oct 15, 7:34 am, Mr.SpOOn <[EMAIL PROTECTED]> wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I
> defined.
>
> Sometimes I need a different behavior of the operator depending on the
> argument. For exa
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I defined.
>
> Sometimes I need a different behavior of the operator depending on the
> argument. For example
On Oct 15, 7:34 am, Mr.SpOOn <[EMAIL PROTECTED]> wrote:
> Hi,
> in a project I'm overloading a lot of comparison and arithmetic
> operators to make them working with more complex classes that I
> defined.
>
> Sometimes I need a different behavior of the operator depending on the
> argument. For exa
Hi,
in a project I'm overloading a lot of comparison and arithmetic
operators to make them working with more complex classes that I
defined.
Sometimes I need a different behavior of the operator depending on the
argument. For example, if I compare a object with an int, I get a
result, but if I com
11 matches
Mail list logo