Alternatively, you can write your own python module that calls electrum functions, import it in the console and call it.
How can I import my module with the Electrum console? I tried changing the path to the script's directory and importing it, but it says the module doesn't exist.