<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>“</span>List<IronPython.NewTypes.System.Object_1$2> isn't
even type-safe for Python classes because IronPython maintains a cache of
generated types and will reuse a type it has previously generated for any new
class you define that's compatible with a previously-defined class.”<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>This has always been a lingering thought in the back of my
head – I’ve been wondering how long it’d be until it came up.<o:p></o:p></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Curt Hagenlocher<br>
<b>Sent:</b> Friday, May 02, 2008 10:17 PM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] List<Python Class><o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<p class=MsoNormal>Well in the example I gave, the type of class foo would genrally
be something like IronPython.NewTypes.System.Object_1$2. There's
not going to be any "native" CLR code to which you can pass a
List<IronPython.NewTypes.System.Object_1$2>, and if you're passing the
data to other Python code, you may as well do it as a Python list or
tuple. It's the "dynamic" thing to do :).<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>List<IronPython.NewTypes.System.Object_1$2> isn't even
type-safe for Python classes because IronPython maintains a cache of generated
types and will reuse a type it has previously generated for any new class you
define that's compatible with a previously-defined class.<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><br>
<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal>On Fri, May 2, 2008 at 9:58 PM, Matthew Barnard <<a
href="mailto:m.stephen.barnard@gmail.com">m.stephen.barnard@gmail.com</a>>
wrote:<o:p></o:p></p>
<p class=MsoNormal>Thanks Curt, in C# I use generics (list & dict)
containing class instances quite often. Is there a caveat to the dynamic typing
that I'm missing? <o:p></o:p></p>
<div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
<br>
<o:p></o:p></p>
<div>
<p class=MsoNormal>On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher <<a
href="mailto:curt@hagenlocher.org" target="_blank">curt@hagenlocher.org</a>>
wrote:<o:p></o:p></p>
<div>
<p class=MsoNormal>This will get you a CLR type directly from your class
object:<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>class foo(object):</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>
pass</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><span style='font-family:"Courier New"'>theType =
clr.GetClrType(foo)</span><o:p></o:p></p>
</div>
<div>
<p class=MsoNormal> <o:p></o:p></p>
</div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'>What use do you have for
creating a generic with the resulting (dynamically-generated) type?<o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class=MsoNormal>On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard <<a
href="mailto:m.stephen.barnard@gmail.com" target="_blank">m.stephen.barnard@gmail.com</a>>
wrote:<o:p></o:p></p>
</div>
</div>
<blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;
margin-left:4.8pt;margin-right:0in'>
<div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'>Is the following the only way
to create a generic containing a python class?<br>
<br>
<br>
from System.Collections.Generic import List<br>
from System import Type<br>
<br>
class Foo:<br>
>>class stuff<<<br>
<br>
l = List[Type.GetType(Foo())]()<br>
<br>
<br>
I assume this is the nature of dynamic typing, but is there a way to get the
type from the classobj, and not an instance?<o:p></o:p></p>
</div>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">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><o:p></o:p></p>
</blockquote>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">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><o:p></o:p></p>
</div>
<p class=MsoNormal><br>
<br clear=all>
<o:p></o:p></p>
</div>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='color:#888888'>-- <br>
___________________________<br>
Matthew Barnard<br>
602 540 0652 </span><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><o:p></o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>