[docs] How to embed python in python ?
Sthanki, Dinesh
SthankiD at us.panasonic.com
Tue Aug 26 23:27:23 CEST 2014
Sorry, 'docs', I did not know who to submit this to.
I need to write an IDE to run some Python Scripts, I could attempt that in C#, but , why not write the actual IDE in python, to run python code ?
Here is some not very successful attempt run Python script (one liner) from python
This is an assortment of things I found on the web, mind you, no one is attempting to run python in a python script (embed python in a python script, how about that for a twist ?).
from ctypes import *
from sys import getsizeof
from binascii import hexlify
xPyLib = windll.LoadLibrary("python34.dll") # This works partially
#xPyLib = windll.LoadLibrary("C:\Python34\DLLs\python3.dll") # This works partially too
xPyLib.Py_SetProgramName();
xPyLib.Py_Initialize();
status = xPyLib.Py_IsInitialized(); # check If Python is Initialized
if status==1:
print ("Python is Initialized Successfully")
vers = xPyLib.Py_GetVersion(); # CHECK OUT THE GARBAGE VERSION DATA HERE
Platform = xPyLib.Py_GetPlatform() # CHECK OUT THE GARBAGE VERSION DATA HERE
print ("Python Vers: "+str(hexlify(string_at(id(vers), getsizeof(vers)))))
print ("Platform: "+str(hexlify(string_at(id(Platform), getsizeof(Platform)))))
#print ("Platform: "+str(xPyLib.Py_GetPlatform()))
Command = "x=2"
status = xPyLib.PyRun_String(Command);
xPyLib.Finalize();
else:
print ("*** Failed to Initialize Python ***")
exit()
Oh, one of the FAQ's should be "How do I submit a question ?"
Thank you for your time.
Dinesh Sthanki
Desk: 770-302-1201
Cell: 678-895-6120
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20140826/a2148eb9/attachment.html>
More information about the docs
mailing list