In a statically-typed language like C#, if you have a reference to an "object", you need to tell the compiler that this object is really a "Foo" in order to use any of Foo's methods with the object. The compiler generates whatever code is necessary to cast the variable to a Foo and will then allow you to use any of Foo's public methods with the object. (In a strongly-typed language like C#, the typecast may also throw an exception if the object isn't really a Foo.)<div>
<br></div><div>Variables don't have types in a dynamically-typed language like Python, so the idea that you can cast the variable to another type simply doesn't exist. Instead, when you call a method by a particular name, the call is dispatched at runtime based on whatever form of method resolution is appropriate for that object.<br>
<div><br></div><div>Side note: for .NET, unless some kind of remoting comes into the picture, all references to an object see the entire object. This is in contrast to COM, where you never really see more than one interface at a time on the object.</div>
<div><br><div class="gmail_quote">On Mon, May 4, 2009 at 2:16 PM, Max Barry <span dir="ltr"><<a href="mailto:max@ford-consulting.com">max@ford-consulting.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks Dave that seemed to work. Can you tell me why this is the case? I<br>
ran the code in python for .NET and it work correctly. I would expect to<br>
have implemented the interface in this way in order to use it.<br>
<br>
Thanks,<br>
Max<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</blockquote></div><br></div></div>