You can use either the [Optional] attribute or the [DefaultParameterValue(null)] attributes on the parameter in the C# signature to mark the parameter as being optional. And if you're using a language that's more friendly to default/optional attributes (e.g. VB.NET) you could just use their native syntax which will generate one of those attributes.
The interesting difference between these is I believe if you're typed to object and do [Optional] you get Missing.Value instead of null so you can disambiguate between the two. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Hardy Sent: Sunday, November 18, 2007 12:31 PM To: Discussion of IronPython Subject: [IronPython] Expose a C# function as a Python function taking a default argument Hi all, I have a function declared in C#: void StartResponse(string status, List response_headers, Tuple exc_info); I need to pass this to a Python function, and the Python function will call it. Currently, the code looks like this: object responsesObj = engine.CallObject(callable, module, environ, new StartResponseDelegate(StartResponse)); This works fine if all three arguments are passed. However, from the Python side start_response has this signature: def start_response(status, response_headers, exc_info=None) So my question is: How do I expose the C# function as a Python function with a default argument? It looks like Runtime.Calls.PythonFunction is what I want, but I couldn't figure out how to call it - I tried tracing the code and ended up in the bowels of the DLR. Thanks, Jeff _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com