[Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Ethan Furman
Just to be clear, this is about NotImplemented, not NotImplementedError. tl;dr When a binary operation fails, should an exception be raised or NotImplemented returned? When a binary operation in Python is attempted, there are two possibilities: - it can work - it can't work The main

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread R. David Murray
See issue 22766 for some background on this question. On Mon, 03 Nov 2014 02:30:53 -0800, Ethan Furman et...@stoneleaf.us wrote: Just to be clear, this is about NotImplemented, not NotImplementedError. tl;dr When a binary operation fails, should an exception be raised or NotImplemented

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Brett Cannon
On Mon Nov 03 2014 at 5:31:21 AM Ethan Furman et...@stoneleaf.us wrote: Just to be clear, this is about NotImplemented, not NotImplementedError. tl;dr When a binary operation fails, should an exception be raised or NotImplemented returned? The docs for NotImplemented suggest it's only for

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread R. David Murray
On Mon, 03 Nov 2014 15:05:31 +, Brett Cannon br...@python.org wrote: On Mon Nov 03 2014 at 5:31:21 AM Ethan Furman et...@stoneleaf.us wrote: Just to be clear, this is about NotImplemented, not NotImplementedError. tl;dr When a binary operation fails, should an exception be raised or

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Ethan Furman
On 11/03/2014 08:12 AM, R. David Murray wrote: On Mon, 03 Nov 2014 15:05:31 +, Brett Cannon br...@python.org wrote: On Mon Nov 03 2014 at 5:31:21 AM Ethan Furman et...@stoneleaf.us wrote: Just to be clear, this is about NotImplemented, not NotImplementedError. tl;dr When a binary

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Antoine Pitrou
On Mon, 3 Nov 2014 08:48:07 -0800 Guido van Rossum gu...@python.org wrote: Gotta be brief, but NotImplemented is for all binary ops. Even in-place ops? Regards Antoine. Power may be an exception because it's ternary? On Nov 3, 2014 8:08 AM, Brett Cannon br...@python.org wrote: On

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Guido van Rossum
Not those. On Nov 3, 2014 8:56 AM, Antoine Pitrou solip...@pitrou.net wrote: On Mon, 3 Nov 2014 08:48:07 -0800 Guido van Rossum gu...@python.org wrote: Gotta be brief, but NotImplemented is for all binary ops. Even in-place ops? Regards Antoine. Power may be an exception because

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Guido van Rossum
Sorry, was too quick. For immutable types __iop__ may not exist and then the fallback machinery should work normally using NotImplemented. But if __iop__ exists it can choose not to allow __rop__, because the type would presumably change. This is probably more predictable. I don't even know if

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Antoine Pitrou
On Mon, 3 Nov 2014 09:05:43 -0800 Guido van Rossum gu...@python.org wrote: Sorry, was too quick. For immutable types __iop__ may not exist and then the fallback machinery should work normally using NotImplemented. But if __iop__ exists it can choose not to allow __rop__, because the type would

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Guido van Rossum
That must be so that an immutable type can still implement __iop__ as an optimization. On Mon, Nov 3, 2014 at 9:10 AM, Antoine Pitrou solip...@pitrou.net wrote: On Mon, 3 Nov 2014 09:05:43 -0800 Guido van Rossum gu...@python.org wrote: Sorry, was too quick. For immutable types __iop__ may

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Ethan Furman
Summary: NotImplemented _should_ be used by the normal and reflected binary methods (__lt__, __add__, __xor__, __rsub__, etc.) NotImplemented _may_ be used by the in-place binary methods (__iadd__, __ixor__, etc.), but the in-place methods are also free to raise an exception. Correct? --

Re: [Python-Dev] The role of NotImplemented: What is it for and when should it be used?

2014-11-03 Thread Guido van Rossum
Sounds good! On Mon, Nov 3, 2014 at 11:33 AM, Ethan Furman et...@stoneleaf.us wrote: Summary: NotImplemented _should_ be used by the normal and reflected binary methods (__lt__, __add__, __xor__, __rsub__, etc.) NotImplemented _may_ be used by the in-place binary methods (__iadd__,

[Python-Dev] [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-03 Thread françai s
I intend to write in lowest level of computer programming as a hobby. It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code? What is the lowest level of programming computers that you can write ? Is binary code? Is hex code? Is

Re: [Python-Dev] [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-03 Thread Ryan Gonzalez
Wait...you sent this to 9fans AND Python Dev??? Why not ask on StackExchange Programmers http://programmers.stackexchange.com/ or something? On Mon, Nov 3, 2014 at 5:19 PM, françai s romaper...@gmail.com wrote: I intend to write in lowest level of computer programming as a hobby. It is true

Re: [Python-Dev] [OFF-TOPIC] It is true that is impossible write in binary code, the lowest level of programming that you can write is in hex code?

2014-11-03 Thread Steven D'Aprano
This is off-topic for this mailing list, as you know. There are some mailing lists which approve of off-topic conversations, but this is not one of those. You could ask on the python-l...@python.org mailing list, where it will still be off-topic, but the people there are more likely to answer.