May i customize basic operator (such as 1==3)?
kanchy kang
zzhikang at hotmail.com
Wed Feb 22 01:25:46 EST 2006
many people write test cases with python scripts.
in these test scripts, there are many validation statements,
for example, in unittest, failUnless(a == b),(a/b may be stringType or
intType...)
during running test scripts, if there is one exception raised from
failUnless, i still do not know a =?, b= ?... i have to add one statment
"print a" or "print b" again...
as i know, there are many validation statements if using python as one test
tool...
i think my suggestion or requirement may benefit users greatly...
best regards!
>From: Steve Holden <steve at holdenweb.com>
>To: python-list at python.org
>Subject: Re: May i customize basic operator (such as 1==3)?
>Date: Tue, 21 Feb 2006 23:29:30 -0500
>
>kanchy kang wrote:
> > Hi,all
> > as we know, we can override the operator of one object(for example
>__eq__).
> > my question is, how to override the basic operator?
> > for example,
> >
> > for any object comparison operator(including litterals),
> > for example,
> > a = "123"
> > b = "321"
> >
> > the boolean equation a == b,
> > i need override "==" operator like this:
> > first display a and b
> >
> > then return real boolean result (a == b).
> >
> > thanks!
>
>This isn't going to be possible without modifying the Python
>interpreter, as the operators are implemented as methods of objects, and
>the built-in objects are programmed in C and not in Python.
>
>regards
> Steve
>--
>Steve Holden +44 150 684 7255 +1 800 494 3119
>Holden Web LLC www.holdenweb.com
>PyCon TX 2006 www.python.org/pycon/
>
>--
>http://mail.python.org/mailman/listinfo/python-list
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
More information about the Python-list
mailing list