Re: epiphany

2013-04-28 Thread 88888 Dihedral
Roy Smith於 2013年4月25日星期四UTC+8上午7時50分33秒寫道: > I discovered something really neat today. > > > > We've got a system with a bunch of rules. Each rule is a method which > > returns True or False. At some point, we need to know if all the rules > > are True. Complicating things, not all the ru

Re: epiphany

2013-04-25 Thread Roy Smith
In article <51792710$0$29977$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > It also says, "Its truth value is true". Why would they document that > > fact if you weren't supposed to use it as a boolean operand? > > You can use *anything* in Python in a boolean context. That's

Re: epiphany

2013-04-25 Thread Steven D'Aprano
On Thu, 25 Apr 2013 08:36:34 -0400, Roy Smith wrote: > In article <5178b1db$0$29977$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> The semantics of NotImplemented is that it is a signal for one object >> to say "I don't know how to do this, let somebody else try". > > That'

Re: epiphany

2013-04-25 Thread Roy Smith
In article <5178b1db$0$29977$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > The semantics of NotImplemented is that it is a signal for one object to > say "I don't know how to do this, let somebody else try". That's precisely the logic here. The rule says, "I don't know how to

Re: epiphany

2013-04-24 Thread Steven D'Aprano
On Wed, 24 Apr 2013 19:25:37 -0700, Ethan Furman wrote: > On 04/24/2013 06:35 PM, Steven D'Aprano wrote: >> Objects are supposed to return NotImplemented from special dunder >> methods like __add__, __lt__, etc. to say "I don't know how to >> implement this method for the given argument". Python w

Re: epiphany

2013-04-24 Thread Ethan Furman
On 04/24/2013 07:20 PM, Chris Angelico wrote: On Thu, Apr 25, 2013 at 11:41 AM, Roy Smith wrote: In article <5178884b$0$29977$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: I don't see why you would need anything like that. Reading further on, I see that you are counting unimp

Re: epiphany

2013-04-24 Thread Ethan Furman
On 04/24/2013 06:35 PM, Steven D'Aprano wrote: Objects are supposed to return NotImplemented from special dunder methods like __add__, __lt__, etc. to say "I don't know how to implement this method for the given argument". Python will then try calling the other object's special method. If both ob

Re: epiphany

2013-04-24 Thread Roy Smith
In article , Chris Angelico wrote: > On Thu, Apr 25, 2013 at 11:41 AM, Roy Smith wrote: > > In article <5178884b$0$29977$c3e8da3$54964...@news.astraweb.com>, > > Steven D'Aprano wrote: > > > >> I don't see why you would need anything like that. Reading further on, I > >> see that you are coun

Re: epiphany

2013-04-24 Thread Chris Angelico
On Thu, Apr 25, 2013 at 11:41 AM, Roy Smith wrote: > In article <5178884b$0$29977$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> I don't see why you would need anything like that. Reading further on, I >> see that you are counting unimplemented rules as true, for some reason

Re: epiphany

2013-04-24 Thread Roy Smith
In article <5178884b$0$29977$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I don't see why you would need anything like that. Reading further on, I > see that you are counting unimplemented rules as true, for some reason > which I don't understand. The top-level logic we need

Re: epiphany

2013-04-24 Thread Steven D'Aprano
On Wed, 24 Apr 2013 19:50:33 -0400, Roy Smith wrote: > I discovered something really neat today. > > We've got a system with a bunch of rules. Each rule is a method which > returns True or False. At some point, we need to know if all the rules > are True. Complicating things, not all the rules

epiphany

2013-04-24 Thread Roy Smith
I discovered something really neat today. We've got a system with a bunch of rules. Each rule is a method which returns True or False. At some point, we need to know if all the rules are True. Complicating things, not all the rules are implemented. Those that are not implemented raise NotIm