Skip to content

Instantly share code, notes, and snippets.

@LukeB42
Created March 9, 2016 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukeB42/3c7afeb25461864fb4db to your computer and use it in GitHub Desktop.
Save LukeB42/3c7afeb25461864fb4db to your computer and use it in GitHub Desktop.
// gcc -c $(python2.7-config --cflags) simplepython.c
// gcc simplepython.o $(/usr/bin/python2.7-config --ldflags) -o simplepython
#include <Python.h>
int main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]); /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment