|
Re: using stdout/stderr with python: msg#00134programming.swig
also sprach Martin F Krafft <krafft@xxxxxxxx> [2004.05.25.0140 +0200]: > Some of my functions take a FILE*. I understand how one can > provide wrappers or a typemap to deal with that, but what if > I want to pass stdout and stderr into these functions as the FILE* > arguments? I could not find a way to do this. I found sys.stdout and sys.stderr, but I can't seem to use them. Neither can I use file objects. I am using the following typemap in the .i file: %typemap(python,in) FILE* { if (!PyFile_Check($input)) { PyErr_SetString(PyExc_TypeError, "need a file!"); return NULL; } $1 = PyFile_AsFile($input); } (basically copied from the docs) but when I ttry to use sys.stdout as a FILE* argument, Python complains: Traceback (most recent call last): File "./test", line 11, in ? phidget_set_debug_stream(f) TypeError: Type error. Expected _p_FILE The same happens if I pass f = open('file', 'w') I would appreciate any tips and pointers! -- Martin F. Krafft Artificial Intelligence Laboratory Ph.D. Student Department of Information Technology Email: krafft@xxxxxxxx University of Zurich Tel: +41.(0)1.63-54323 Andreasstrasse 15, Office 2.18 http://ailab.ch/people/krafft CH-8050 Zurich, Switzerland Invalid/expired PGP subkeys? Use subkeys.pgp.net as keyserver! Spamtraps: krafft.bogus@xxxxxxxx madduck.bogus@xxxxxxxxxxx "when a woman marries again it is because she detested her first husband. when a man marries again it is because he adored his first wife. women try their luck; men risk theirs." -- oscar wilde
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: how to prevent objects from being garbage collected.: 00134, Marcelo Matus |
|---|---|
| Next by Date: | pointers to pointers: 00134, Martin F Krafft |
| Previous by Thread: | using stdout/stderr with pythoni: 00134, Martin F Krafft |
| Next by Thread: | Re: Re: using stdout/stderr with python: 00134, Kevin Smith |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |