Add the following to .lyx/externaltemplates (modify accordingly to python, this is C++ (cpp)
Template CppKod GuiName "[C++ $$Basename]" HelpText Snyggar till C++ kod HelpTextEnd InputFormat cpp FileFilter "*.{cpp,h,hpp,c}" ViewCommand "nedit $$FName" EditCommand "nedit $$FName" AutomaticProduction true Format LaTeX Product "{\\small \\input{$$FName.tex} }" UpdateFormat latex #UpdateCommand "highlight -A -L -t 4 -I -S cpp -f -r -q $$FName -o $$FName.tex" UpdateResult "$$FName.tex" FormatEnd Format PDFLaTeX FormatEnd TemplateEnd You have to add the corresponding filetypes and converters in the lyx configuration, or simply add these lines to .lyx/preferences: \format "cpp" "cpp" "C++" "" "" "nedit" \converter "cpp" "latex" "highlight -A -L -t 4 -I -S cpp -f -r -q $$FName -o $$FName.tex" "" This should do the trick. Remember to change cpp to something python-ish. This is for lyx 1.4 and above, below that, search the mailing list for a similar posting.