Nathaniel Smith wrote: > There are a number of callbacks in rinterface that one can set to > control R's console -- setWriteConsole, setReadConsole, etc. This > patch fixes to limitations with the current API:
Thanks. Can you sent it again ? The patch seems to have gotten eaten on the way. > 1) It is impossible to read out the current callback. This would be > useful for switching another callback into place temporarily, as in > something like: > > def my_repr(robj): > saved = rinterface.getWriteConsole() > buf = [] > def capture(s): > buf.append(s) > try: > rinterface.setWriteConsole(capture) > r["print"](robj) > finally: > rinterface.setWriteConsole(saved) > return "".join(buf) Indeed. I agree. I have been also considering putting all callbacks as attributes of a structure (since there are more callbacks in the dev version). Now I see that this could also solve the issue you are describing. > 2) The initial callback is NULL, but once a callback has been set, it > is impossible to set it back to NULL. In practice this isn't really a > problem, but in principle it could break the above idiom. It is set to NULL at the C-level to cut corners (limited development time), and getting back to NULL should not be done (it might end in a segfault). The Python-level __init__.py in rinterface is immediately setting a value. > The attached patch adds getWriteConsole and friends, and defines them > to return None when a callback is unset, and allows None to be passed > back to setWriteConsole and friends to explicitly unset the > corresponding callback. > > The patch builds and contains tests, but I haven't actually tested it > -- easy_install <my checkout> is producing a rinterface.so that fails > to import ("undefined symbol: R_ProcessEvents"). Probably just > something odd about my setup (though easy_install rpy2-2.0.1.tar.gz > worked fine), but FYI. It should build. Is that a checkout from the tip at bitbucket ? What platform are you on (OS, R version, Python version). Thanks, L. > Thanks, > -- Nathaniel > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list