<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></div><div><div>On Mar 9, 2010, at 13:26 , Andrey Fedorov wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">So I have `x', a instance of class `Foo'. I also have class `Bar', a class extending `Foo' with a couple of methods. I'd like to "down cast" x as efficiently as possible. Is it OK to just set `x.__class__ = Bar' and expect things to work OK in all major versions of CPython? </blockquote><br></div><div>Could you tell us *why* you need to down-cast x? Explicit type-casting is usually unnecessary in Python...</div><br><div><span class="Apple-style-span" style="font-size: 12px; "><div>-------------</div><div>Rami Chowdhury</div><div>"Never assume malice when stupidity will suffice." -- Hanlon's Razor</div><div>408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)</div><div><br></div></span></div></body></html>