[IronPython] Calling functions in IronPython that don't really exist

Jeff Slutter jslutter at reactorzero.com
Thu Dec 4 22:30:24 CET 2008


Ok, now I feel a little stupid. Thanks :)

I think it would be wise to drop the "params object[] args" and go with
just actually specifying the parameters to the constructor so I can take
advantage of type checking, etc. from Python.

In the constructor I'll have to save the instance of the class created
to my internal History list (for the undo, redo).

Thanks again!

Dino Viehland wrote:
> Do you mean you'd call it like "AddNumbers().Do(3, 4)"?
>
> This is really easy.  Make AddNumbers public, then do:
>
> import clr
> clr.AddReference('MyAssembly')
> import AddNumbers
> AddNumbers().Do(3, 4)
>
> If you really want to do AddNumbers(3, 4) then you'd just write it as:
>
> public class AddNumbers
> {
>     public AddNumbers(params object[] args) {
>          Do(args);
>     }
>     public string Do( params object[] args )
>     {
>         ..check args..
>         ..add the two arguments..
>         ..return the result as a string..
>     }
> }
>
> And do the same:
>
> import clr
> clr.AddReference('MyAssembly')
> import AddNumbers
> AddNumbers(3, 4)
>
>   
>



More information about the Ironpython-users mailing list