<div class="gmail_quote">On Fri, Jun 25, 2010 at 6:15 AM, WANG Cong <span dir="ltr"><<a href="mailto:xiyou.wangcong@gmail.com">xiyou.wangcong@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

4) Also, this will _somewhat_ violate the OOP princples, in OOP,<br>
this is and should be implemented by inherence.<br></blockquote><div><br></div><div>Others have answered the rest fine, I just wanted to add: Who says we have to follow OOP principles, huh?</div><div><br></div><div>If you want to follow OOP principles: Python will do absolutely nothing to stop you! All power to you.</div>

<div><br></div><div>You're also free to break the principles if you choose to: this is the key point. Python lets you choose to. If you firmly believe in the principles, you can embrace them fully by simply never choosing to violate them in any way. </div>

<div><br></div><div>Some languages force you to adopt the OOP paradigm and build its principles directly into the language. Python does not. A python "object" is not, necessarily, the same thing as an abstract Object in the OOP world. But you can use it as such an object if you want and do everything OOP needs, though some things (such as encapsulation) are done by convention more then a strict enforcement by the language. </div>

<div> </div><div>Or you can use it and abuse it and do some really interesting and slightly crazy things as you experiment with other paradigms (even some lesser known ones), perhaps inventing a new paradigm all together. :)</div>

<div><br></div><div>Most of my code is pretty OOPish. But I have more then a few places where I dig out my metaclass dark magic and transform objects into some distinctly unique tool.</div><div><br></div><div>Python's content with letting me do that. Not that I'd show anyone or admit to my vices publicly, though. :)</div>

<div><br></div><div>--S</div></div>