Re: Override 'and' and 'or'

2007-10-08 Thread Andrew Durdin
On 10/7/07, Dekker <[EMAIL PROTECTED]> wrote: > > Well I think it is not possible what I wanted to achieve. By > overriding the "and" and "or" keyword I wanted to return a new object: > > SqlValueInt(4) and SqlValueInt(5) --> SqlOpAnd(SqlValueInt(4), > SqlValueInt(5)) PEP 335 is a proposal to allo

Re: Override 'and' and 'or'

2007-10-07 Thread John Machin
On 8/10/2007 1:57 AM, Diez B. Roggisch wrote: > Kay Schluehr schrieb: >> You can see what "and" and "or" are actually doing: >> >> import dis >> dis.dis(lambda: x or y and z) >> >> 1 0 LOAD_GLOBAL 0 (x) >> 3 JUMP_IF_TRUE11 (to 17) >>

Re: Override 'and' and 'or'

2007-10-07 Thread Diez B. Roggisch
Kay Schluehr schrieb: > On Oct 7, 4:48 pm, Dekker <[EMAIL PROTECTED]> wrote: >> On 7 Okt., 16:19, Steven D'Aprano <[EMAIL PROTECTED] >> >> cybersource.com.au> wrote: >>> On Sun, 07 Oct 2007 13:52:15 +, Dekker wrote: Is it possible to override 'and' and/or 'or'? >>> Not without hacking the

Re: Override 'and' and 'or'

2007-10-07 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Sun, 07 Oct 2007 16:24:35 +0200, Wildemar Wildenburger wrote: > >> Wildemar Wildenburger wrote: >>> [whate everyone else wrote :(] >>> >>> /W >> Dangit! 4th of 4. >> Gotta type quicker. > > > That's okay, in two weeks time there will be 139 messages in this thread,

Re: Override 'and' and 'or'

2007-10-07 Thread Kay Schluehr
On Oct 7, 4:48 pm, Dekker <[EMAIL PROTECTED]> wrote: > On 7 Okt., 16:19, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > On Sun, 07 Oct 2007 13:52:15 +, Dekker wrote: > > > Is it possible to override 'and' and/or 'or'? > > > Not without hacking the Python source code, in w

Re: Override 'and' and 'or'

2007-10-07 Thread Wildemar Wildenburger
Dekker wrote: > Well... I have to live with the (binary) __and__, __or__ option and > the user has to write: > > SqlValueInt(4) & SqlValueInt(5) --> SqlOpAnd(SqlValueInt(4), > SqlValueInt(5)) > > Thanks for your input, but __nonzero__ is not of any help in this > case... I want to abuse the "magi

Re: Override 'and' and 'or'

2007-10-07 Thread Dekker
On 7 Okt., 16:19, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sun, 07 Oct 2007 13:52:15 +, Dekker wrote: > > Is it possible to override 'and' and/or 'or'? > > Not without hacking the Python source code, in which case what you've got > is no longer Python. > > Why do you w

Re: Override 'and' and 'or'

2007-10-07 Thread Steven D'Aprano
On Sun, 07 Oct 2007 16:24:35 +0200, Wildemar Wildenburger wrote: > Wildemar Wildenburger wrote: >> [whate everyone else wrote :(] >> >> /W > > Dangit! 4th of 4. > Gotta type quicker. That's okay, in two weeks time there will be 139 messages in this thread, it will have devolved into an argume

Re: Override 'and' and 'or'

2007-10-07 Thread Wildemar Wildenburger
Wildemar Wildenburger wrote: > [whate everyone else wrote :(] > > /W Dangit! 4th of 4. Gotta type quicker. /W -- http://mail.python.org/mailman/listinfo/python-list

Re: Override 'and' and 'or'

2007-10-07 Thread Wildemar Wildenburger
Dekker wrote: > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? > > Have marvelous sunday, > Marco > I guess you're looking for __nonzero__() http://docs.python.or

Re: Override 'and' and 'or'

2007-10-07 Thread Steven D'Aprano
On Sun, 07 Oct 2007 13:52:15 +, Dekker wrote: > Is it possible to override 'and' and/or 'or'? Not without hacking the Python source code, in which case what you've got is no longer Python. Why do you want to do so? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list

Re: Override 'and' and 'or'

2007-10-07 Thread Bruno Desthuilliers
Dekker a écrit : > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? http://docs.python.org/ref/customization.html """ __nonzero__(self) Called to implement t

Re: Override 'and' and 'or'

2007-10-07 Thread Lawrence Oluyede
Dekker <[EMAIL PROTECTED]> wrote: > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? If you want to customize the truth value testing you have to implement __nonzero_