[IronPython] 2.0B1 Hosting: Creating Python Types

Jeff Hardy jdhardy at gmail.com
Tue Mar 18 14:45:59 CET 2008


Hi Dino,

On Mon, Mar 17, 2008 at 6:26 PM, Dino Viehland
<dinov at exchange.microsoft.com> wrote:
> 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.

Sounds good.

>
> 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).

That's actually what I thought when I was trying to sleep last night
:). It's certainly acceptable, and I'm not sure using Streams as files
will be all that common anyway, but it seems that it could hang off of
ScriptEngine (i.e. engine.MakeFile(Stream)). However, I don't know how
applicable that we be to other languages (it's been a while since I
used Ruby). If you can think of a place to put it, great; if not, I
won't lose any (more) sleep over it.

Aside: I like the new ObjectOperations class. It makes a lot of the
stuff I have to do for NWSGI much easier. All of the new hosting APIs
are very nice to work with.

Thanks for your help, Dino.

-Jeff

>
>
>
> -----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
> _______________________________________________
> 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