[IPython-user] FW: embedding IPython in windows dll
Alexander Belchenko
bialix@ukr....
Mon Mar 10 15:02:13 CDT 2008
mani sabri пишет:
>
>> -----Original Message-----
>> From: mani sabri [mailto:mani.sabri@gmail.com]
>> Sent: Monday, March 10, 2008 12:56 PM
>> To: 'Alexander Belchenko'
>> Subject: RE: [IPython-user] embedding IPython in windows dll
>>
>> OK, now I have a console and the HANDLEs of stdout, stdin and stderr.
>>
>> BOOL res = AllocConsole();
>> HANDLE OutHand = GetStdHandle(STD_OUTPUT_HANDLE);
>> HANDLE InHand = GetStdHandle(STD_INPUT_HANDLE);
>> HANDLE ErrHand = GetStdHandle(STD_ERROR_HANDLE);
>> Py_Initialize();
>> if (!Py_IsInitialized()) return(FALSE);
>> import_array1(-1);
>> modstring = PyString_FromString("numpy");
>> mod = PyImport_Import(modstring);
>>
>> PyRun_SimpleString("dt = numpy.dtype([('ctm', uint), ('open',
>> double), ('low', double), ('high', double), ('close', double), ('vol',
>> double)])");
>> PyRun_SimpleString("from IPython.Shell import IPShellEmbed");
>> PyRun_SimpleString("ipshell = IPShellEmbed()");
>> PyRun_SimpleString("ipshell()");
>>
>> Can I redirect the Ipython to standard console?
I never did it before and can't find examples in google.
I think you should attach file-like objects (corresponding to new stdin/stdout/stderr)
to sys.stdin/sys.stdout/sys.stderr,
but without digging in Python C sources I can't say how exactly. May be you'd get lucky
on pywin32 ML, as other people suggested.
More information about the IPython-user
mailing list