When creating custom marking menu where you want to add some of your own scripts there is no option to directly add few lines of Python code since marking menu seems to support only MEL directly.
It would be great if you can choose the language of your script there in Marking Menu just like you can, for example, for shelf buttons (when you edit them) or for custom hotkeys....like on this image below.
It is a pain to save file externally for some small script just so that you can call for it in marking menu again. I also prefer to save/backup making menu only as one file but not multiple files which i might even forget what is what when you reinstall or update to a newer version of Maya.