The idea: using the Python interpreter as an InteractiveShell. = Command execution = Use short method names: {{{ #!python def S(arg): """returns string of executed command arg""" return os.popen(arg).read() def SN(arg): """returns list of executed command arg""" return os.popen(arg).read().split('\n') def SP(arg): """prints string of executed command arg""" print S(arg) def SNP(arg): """prints with lines list executed command arg""" for i in SN(arg): print i }}} Command execution is the one thing an InteractiveShell has to be good at. Typing S("") is too much overhead for command execution. Still, a mixture of bash style command execution and shell programming with Python would be great. ---- I'd want the simple style of command execution from bash available: {{{ cd /foo/bar }}} But also the Python style for more complex commands: {{{ os.setcwd('/foo/bar') }}} Some ways to execute the bash-style command: * Use os.popen(). * Map all commands to Python functions: cd(), less(), all taking a list of strings as arguments. * Completely separate bash-style commands from Python commands, executing it with bash. -- JohannesGijsbers <> There is a project that attempts to acheive this. Quasi (http://quasi-shell.sourceforge.net/) provides a shell within which Python can be freely mixed with OS (and certain database) commands. -- BenLast This sounds a lot like [[lwickjr/Modules]]/Alias.py when coupled with a module of shell-command functions. See [[lwickjr/Modules]] for further information. --[[lwickjr]] = Path manipulation = The os.path module provides a good set of functions for path manipulation, but you might also want to split the path at the root: {{{ #!python import re def splitroot(s): if "/" not in s: return '',s if s[0] == '/': s = s[1:] m = re.match("(.*?)/(.*)$",s) return m.groups() }}} = awk comparables = Simply use the re module. It's a fuller set of regular expressions. Create a wrapper function for a utility for this if you want call it inlinegrep. = Limitations = The killall function was rejected by the [[BDFL]]. As far as I can see from the previous version of this page, Guido rejected it because it isn't in POSIX. I couldn't find any references on this in the mailing list archives. Anyone? See also: * [[http://www.gregorpurdy.com/gregor/psh/|The Perl Shell]]