Re: [Tutor] class questions

2010-06-27 Thread Hugo Arts
On Sun, Jun 27, 2010 at 6:47 PM, Shashwat Anand wrote: > >> >> The problem of the MRO isn't that it doesn't work, it's that it causes >> behavior that is unintuitive. In my example, We would expect D.x to be >> equal to C.x (since D inherits from C, and C overrides the x method). >> However, this

Re: [Tutor] class questions

2010-06-27 Thread Shashwat Anand
> The problem of the MRO isn't that it doesn't work, it's that it causes > behavior that is unintuitive. In my example, We would expect D.x to be > equal to C.x (since D inherits from C, and C overrides the x method). > However, this is not the case. This is what the problem is with the > old MRO

Re: [Tutor] class questions

2010-06-27 Thread Hugo Arts
On Sun, Jun 27, 2010 at 4:13 PM, Payal wrote: > Hi Hugo, > > On Sun, Jun 27, 2010 at 01:27:37PM +0200, Hugo Arts wrote: >> Here's my attempt. Consider this simple Diamond hierarchy: > [...] >> Now, with this diagram the following code probably doesn't do what you >> expect: > > Actually, it does

Re: [Tutor] class questions

2010-06-27 Thread Payal
Thanks a lot Eike for the code snippet. I got the idea now. With warm regards, -Payal -- On Sat, Jun 26, 2010 at 10:41:59PM +0200, Eike Welk wrote: > Hello Payal! > > On Saturday June 26 2010 19:05:16 Payal wrote: > > Can we say that our own exception classes have only maybe a doc-string > > a

Re: [Tutor] class questions

2010-06-27 Thread Payal
Hi Steven, Thanks a lot for patiently explaining the concepts. I uderstood most of it. With warm regards, -Payal -- On Sun, Jun 27, 2010 at 10:09:38AM +1000, Steven D'Aprano wrote: > Probably not... it's quite complicated, which is why it's rare. I'll > have a think about it and see what I ca

Re: [Tutor] class questions

2010-06-27 Thread Payal
Hi Hugo, On Sun, Jun 27, 2010 at 01:27:37PM +0200, Hugo Arts wrote: > Here's my attempt. Consider this simple Diamond hierarchy: [...] > Now, with this diagram the following code probably doesn't do what you expect: Actually, it does what is expected. The old mro specifically says, bottom-top, le

Re: [Tutor] class questions

2010-06-27 Thread Hugo Arts
On Sun, Jun 27, 2010 at 2:09 AM, Steven D'Aprano wrote: > On Sun, 27 Jun 2010 03:05:16 am Payal wrote: >> >> Can you give any simple example where this simple mro will work >> incorrectly? > > Probably not... it's quite complicated, which is why it's rare. I'll > have a think about it and see what

Re: [Tutor] class questions

2010-06-26 Thread Steven D'Aprano
On Sun, 27 Jun 2010 03:05:16 am Payal wrote: > Thanks a lot for the quick answer. Still some doubts below. > > On Sat, Jun 26, 2010 at 11:07:17PM +1000, Steven D'Aprano wrote: > > The old MRO (Method Resolution Order) is broken for classes using > > multiple inheritance with a diamond shape inherit

Re: [Tutor] class questions

2010-06-26 Thread Christopher King
only new classes can have properties, a major tool On Sat, Jun 26, 2010 at 8:17 AM, Payal wrote: > Hi, > Some questions about which I am a bit confused. > > 1. I know there is a difference between mro of classic and new style > classes. but I do not get why we need the new mro, the old one is eas

Re: [Tutor] class questions

2010-06-26 Thread Christopher King
Well the application of defining ones own error is in a module. For example, if I make a banking account module, I might define a WithdrawError if there is a place where a error might occur. That way if client code tries to withdraw too much, you can have a very descriptive error making it easier t

Re: [Tutor] class questions

2010-06-26 Thread Eike Welk
Hello Payal! On Saturday June 26 2010 19:05:16 Payal wrote: > Can we say that our own exception classes have only maybe a doc-string > and pass, nothing more? No, you let the exception transport the information that you need for handling the error. This is an exception that I use to transport us

Re: [Tutor] class questions

2010-06-26 Thread Payal
Thanks a lot for the quick answer. Still some doubts below. On Sat, Jun 26, 2010 at 11:07:17PM +1000, Steven D'Aprano wrote: > The old MRO (Method Resolution Order) is broken for classes using > multiple inheritance with a diamond shape inheritance diagram. Not a > little bit broken, but horribl

Re: [Tutor] class questions

2010-06-26 Thread Steven D'Aprano
On Sat, 26 Jun 2010 10:17:45 pm Payal wrote: > Hi, > Some questions about which I am a bit confused. > > 1. I know there is a difference between mro of classic and new style > classes. but I do not get why we need the new mro, the old one is > easy to predict and understand? The old MRO (Method Re

[Tutor] class questions

2010-06-26 Thread Payal
Hi, Some questions about which I am a bit confused. 1. I know there is a difference between mro of classic and new style classes. but I do not get why we need the new mro, the old one is easy to predict and understand? 2. A friend of mine told me that in C++ abstract classes are classes which can