[PATCH] Some new stuff

Stelios Xanthakis sxanth at ceid.upatras.gr
Sun Nov 14 09:55:12 CET 2004

Hi all.

Basically, I'd like to use python as my system shell. It's not suitable 
for a general purpose shell but since it is very programmable it can 
eventually do whatever bash does and even more.

One thing I'd like python to do is: attach the *python code* of a 
function to a function object. The same for class.

This can be done in python as it is but it doesn't feel very right. I 
think it should be the job of the parser. So there is a patch vs 2.3.4 at:

With this patch when the command line option -P is passed to python,
all functions and classes have an extra member __pycode__ which is the
code of the thing!

This is very exciting because if combined with a function 'save()' which
looks for all the functions/classes in globals(), takes their __pycode__ 
and saves it to a file (along with it's own code: save.__pycode__) can 
lead to a really fun Python Incremental Expert System Shell.

Such a sample system is also included in the tar file.
For example we can say:
   lsfunc()     # lists all functions
   pr (lsfunc)  # prints definition of lsfunc
   ed (pr)      # edits the function 'pr'
   save ()      # saves all and we go to sleep



More information about the Python-list mailing list