[IronPython] ironpython alternative to PyOS_ReadlineFunctionPointer

Jörgen Stenarson jorgen.stenarson at bostream.nu
Thu Jun 29 21:14:22 CEST 2006


Dino,
I've been sucessful in locating ReadLineFromSrc but not IConsole (from 
the IronPythonConsole). However ReadLineFromSrc is a read only attribute 
in the IronPython.Runtime.Operations.Ops module. Ideally I would like to 
do something like this:

import IronPython

def my_readline():
     txt=System.Console.ReadLine()
     return txt

IronPython.readline=my_readline

But I guess it could be difficult if what I want to override a method in 
a class instance written in C#. Am I right? Could this be changed in 
that case?

/Jörgen



Dino Viehland skrev:
> Ops.ReadLineFromSrc will be called if for example someone calls raw_input() from Python (one way to read from the user).  IConsole.ReadLine gets called when we're reading input from the console for some code you're typing in.
> 
> I think ideally these would be using the same underlying implementation but do to the extra things our fancy console does they're rather divergent today.  For readline I suspect you'll want to be updating IConsole.ReadLine instead.
> 
> Also it'd be great if you could keep us updated when you get something working.  One of our PMs has wanted good history support, and I think Bruce (who implemented socket as part of his internship this summer) might prefer readline's key bindings :).
> 
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jörgen Stenarson
> Sent: Wednesday, June 28, 2006 2:21 PM
> To: Discussion of IronPython
> Subject: Re: [IronPython] ironpython alternative to PyOS_ReadlineFunctionPointer
> 
> Thanks for the response, I will have to investigate this further.
> 
> Just to clarify, what I want to do is replace the function that is called by the ironpython interpreter to read a line of text from the user.
> 
> /Jörgen
> 
> Dino Viehland skrev:
>> Is IronPython.Runtime.Operations.Ops.ReadLineFromSrc what you're looking for?  This allows you to read a line of input from std-in.
>>
>> I'm not familiar w/ CPython's internal interfaces so I'm not sure if that's right or not...  The other option is that this is the functionality that lives in the console, and you want IConsole.ReadLine.
>>
>> Currently these two are rather disconnected.
>>
>> -----Original Message-----
>> From: users-bounces at lists.ironpython.com
>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jörgen
>> Stenarson
>> Sent: Wednesday, June 28, 2006 11:44 AM
>> To: Discussion of IronPython
>> Subject: [IronPython] ironpython alternative to
>> PyOS_ReadlineFunctionPointer
>>
>> Hi,
>>
>> I'm working on a python based implementation of readline (pyreadline available from http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro). I'm experimenting with adding support for ironpython, I have been successful in porting some of the ctypes based routines used for keyboard event processing to ironpython using System.Console. It has been quite painless so far.
>>
>> But to take this further I need to know the ironpython equivalent to PyOS_ReadlineFunctionPointer in cpython and how to use it. Is this functionality exposed and if not do you plan to expose it?
>>
>> Best regards,
>> Jörgen Stenarson
>>
>> _______________________________________________
>> 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
>>
> 
> _______________________________________________
> 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