[IronPython] 2.0B1 Hosting: Creating Python Types

Dino Viehland dinov at exchange.microsoft.com
Tue Mar 18 01:26:46 CET 2008


MakeTuple has been moved into PythonOps as PythonOps.MakeTuple.  The reason for that change is that we now want the public surface area of the .NET Python types to match the public surface area Python types.

File is more of a problem...  Unfortunately files do need to be bound to a context (for multi-runtime support).  If there's enough demand for it we could provide a PythonEngine class which is compatible w/ 1.x and we could expose the file creation via that.  Until then probably the only way to do it right now is to call __builtin__.file through Python code (to which you can pass in a stream).  The ObjectOperations class should make that fairly easy (you can convert file to a delegate and then call it).

CodeContext isn't actually internal but it's also not available to you via the hosting APIs.  Basically the DLR APIs are split into hosting APIs and language APIs.  The hosting APIs provide a pretty interface as well as a remoting model and the language APIs provide a ton of functionality specific to language implementers.


-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy
Sent: Monday, March 17, 2008 7:17 PM
To: Discussion of IronPython
Subject: [IronPython] 2.0B1 Hosting: Creating Python Types

Hi,
I'm trying to figure out how to create an instance of a Python type
(i.e. tuple and file) using the hosting interface (from C#). In older
versions there was PythonTuple.MakeTuple, for example, but that seems
to have disappeared. Now PythonTuple and PythonFile both require a
CodeContext, which I'm pretty sure is internal.

Is there a nice, easy way in 2.0B1 to create a tuple and convert a
Stream to a file-like object?

Thanks,
Jeff
_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list