It's not a problem at all.<br><br>I was just trying to test the API for a library from the interactive interpreter. When it happened, I remembered that it had bit me before, and this time I just happened to be in a mood to track it down.
<br><br>Thanks,<br>Eric<br><br><div><span class="gmail_quote">On 7/30/07, <b class="gmail_sendername">John Messerly</b> <<a href="mailto:jomes@microsoft.com">jomes@microsoft.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
For what it's worth, this appears to be fixed in IronPython 2.0 alpha 3:<br><br>>ipy paramcalltest.py<br>args = System.String[]('a', 'b', 'c')<br>creating ParamCall object:<br>pc.Joined() => a,b,c
<br><br>If it's really bothersome we could add it to the 1.1.1 bug list, but in the meantime I'd suggest the workaround Michael mentioned (wrapping the args up in the tuple)<br><br>Cheers,<br>John<br><br>-----Original Message-----
<br>From: <a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com">users-bounces@lists.ironpython.com</a>] On Behalf Of Eric Rochester
<br>Sent: Monday, July 30, 2007 1:37 PM<br>To: IronPython Users<br>Subject: [IronPython] CLR class constructors and arrays<br><br>Hi,<br><br>I've been using IronPython for a few months now, and I'm really enjoying it. Thanks for all the hard work that's gone into it.
<br><br>I recently ran across an issue, and I wondered if anyone else has seen it. I think it's probably a bug, but I couldn't find a bug report, either.<br><br>Basically, if there is a CLR class that takes an array as its only constructor argument, IronPython always tries to call it using params. For example, if I compile this to
ParamCall.dll:<br>// ParamCall.cs<br><br>using System;<br><br>namespace ParamCall<br>{<br> public class ParamCall<br> {<br> private string[] args;<br><br> public ParamCall(string[] args)<br> {<br>
this.args = args;<br> }<br><br> public string Joined()<br> {<br> return String.Join(",", args);<br> }<br> }<br>}<br><br>And I call it using this script:<br>#
paramcall.py<br><br>import clr<br>clr.AddReference('ParamCall')<br><br>from ParamCall import ParamCall<br>from System import Array<br><br>args = Array[str]( ['a', 'b', 'c'] )<br>print 'args =', args
<br><br>print 'creating ParamCall object:'<br>pc = ParamCall(args)<br>print 'pc.Joined() =>', pc.Joined()<br><br>print<br><br>I get these results.<br>C:\home\eric\src\ase\Lse.Net>IronPython\ipy paramcall.py
<br>args = System.String[]('a', 'b', 'c')<br>creating ParamCall object:<br>Traceback (most recent call last):<br> File C:\home\eric\src\ase\Lse.Net\paramcall.py, line 7, in Initialize<br> File , line 0, in __import__##4
<br> File C:\home\eric\src\ase\Lse.Net\ParamCall.py, line 15, in Initialize<br> File , line 0, in NonDefaultNew##54<br>TypeError: ParamCall() takes exactly 1 argument (3 given)<br><br>I have also tried wrapping the arguments in a tuple and calling it like ParamCall( *(args,) ), but the results are the same.
<br><br>If anyone has any suggestions for work-arounds or clues as to what I'm doing wrong, I'd be glad to hear them.<br><br>Thanks,<br><br>--<br>Eric Rochester<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">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
</a><br></blockquote></div><br><br clear="all"><br>-- <br>Eric Rochester<br><a href="http://writingcoding.blogspot.com/">http://writingcoding.blogspot.com/</a><br><a href="http://www.linkedin.com/in/erochester">http://www.linkedin.com/in/erochester
</a>