Re: Overloading the tilde operator?

2007-02-08 Thread gatti
On Feb 8, 7:02 am, Dave Benjamin [EMAIL PROTECTED] wrote: Neil Cerutti wrote: There's been only one (or two?) languages in history that attempted to provide programmers with the ability to implement new infix operators, including defining precedence level and associativity (I can't think

Re: Overloading the tilde operator?

2007-02-08 Thread Markus Triska
[EMAIL PROTECTED] writes: Also some flavours of Prolog, as descrived in the classic book by op/3 is part of the Prolog ISO standard: http://pauillac.inria.fr/~deransar/prolog/bips.html#operators so every compliant implementation has it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Overloading the tilde operator?

2007-02-07 Thread Dave Benjamin
Neil Cerutti wrote: There's been only one (or two?) languages in history that attempted to provide programmers with the ability to implement new infix operators, including defining precedence level and associativity (I can't think of the name right now). You're probably thinking of SML or

Re: Overloading the tilde operator?

2007-02-07 Thread greg
Dave Benjamin wrote: Neil Cerutti wrote: There's been only one (or two?) languages in history that attempted to provide programmers with the ability to implement new infix operators, including defining precedence level and associativity (I can't think of the name right now). You're

Re: Overloading the tilde operator?

2007-02-02 Thread Neil Cerutti
On 2007-02-02, Ben Finney [EMAIL PROTECTED] wrote: James Stroud [EMAIL PROTECTED] writes: Ben Finney wrote: The Python runtime parser is designed to parse Python, not some arbitrary language that someone chooses to implement in Python. You haven't addressed why the limitation isn't

Re: Overloading the tilde operator?

2007-02-02 Thread greg
James Stroud wrote: You haven't addressed why the limitation isn't arbitrary. It's not arbitrary because there is a built-in meaning for infix minus, but not for infix tilde. Python doesn't go out of its way to provide operators which aren't used by at least one built-in type. -- Greg --

Overloading the tilde operator?

2007-02-01 Thread Chris
I am trying to overload the __invert__ operator (~) such that it can take a second argument, other than self, so that I can express: x ~ y by using: def __invert__(self, other): do something for example. Is this possible? Thanks in advance, --

Re: Overloading the tilde operator?

2007-02-01 Thread Peter Otten
Chris wrote: I am trying to overload the __invert__ operator (~) such that it can take a second argument, other than self, so that I can express: x ~ y by using: def __invert__(self, other): do something for example. Is this possible? No, you will get a syntax error before python

Re: Overloading the tilde operator?

2007-02-01 Thread bearophileHUGS
Peter Otten: No, you will get a syntax error before python even look up the names: There are some tricks that allow the use of undefined symbols in Python too, but they are probably just toys. I have recently posted a recipe in the cookbook for that. Bye, bearophile --

Re: Overloading the tilde operator?

2007-02-01 Thread James Stroud
Peter Otten wrote: Chris wrote: I am trying to overload the __invert__ operator (~) such that it can take a second argument, other than self, so that I can express: x ~ y by using: def __invert__(self, other): do something for example. Is this possible? No, you will get a syntax

Re: Overloading the tilde operator?

2007-02-01 Thread Ben Finney
James Stroud [EMAIL PROTECTED] writes: Peter Otten wrote: Chris wrote: I am trying to overload the __invert__ operator (~) such that it can take a second argument, x ~ x File stdin, line 1 x ~ x ^ SyntaxError: invalid syntax Seems an arbitrary limitation. Consider

Re: Overloading the tilde operator?

2007-02-01 Thread James Stroud
Ben Finney wrote: James Stroud [EMAIL PROTECTED] writes: Peter Otten wrote: Chris wrote: I am trying to overload the __invert__ operator (~) such that it can take a second argument, x ~ x File stdin, line 1 x ~ x ^ SyntaxError: invalid syntax Seems an arbitrary limitation.

Re: Overloading the tilde operator?

2007-02-01 Thread George Sakkis
On Feb 2, 12:49 am, James Stroud [EMAIL PROTECTED] wrote: Ben Finney wrote: The Python runtime parser is designed to parse Python, not some arbitrary language that someone chooses to implement in Python. You haven't addressed why the limitation isn't arbitrary. Indeed, and that's because

Re: Overloading the tilde operator?

2007-02-01 Thread Ben Finney
James Stroud [EMAIL PROTECTED] writes: Ben Finney wrote: The Python runtime parser is designed to parse Python, not some arbitrary language that someone chooses to implement in Python. You haven't addressed why the limitation isn't arbitrary. Good thing I wasn't trying to do that, then. I