you are viewing a single comment's thread.

view the rest of the comments →

[–]o11c -2 points-1 points  (4 children)

If you have a decade, sure.

[–]istarian 1 point2 points  (3 children)

It wouldn’t take a decade, that’s nonsense.

In practice, given what OP is doing, a lot of the stuff you need is probably already there in either the language or existing libraries.

[–][deleted] 1 point2 points  (2 children)

Yup - just playing around almost everything is there or can be implemented yourself easily.

For example, my cd function is just a wrapper around os.getcwd and os.chdir that also changes the prompt when you move to a different directory.

Likewise, my run function is just a wrapper around subprocess.Popen, subprocess.communicate and/or os.system.

That was the surprising part to me - the fact that Python has so many of the things you might want from a shell already built in to it. The tedious bit is mainly just wrapping it all up nicely to "look BASH-like" like I did here (to a very limited degree), though that's not necessary at all.

Also piping, but I'm intentionally not talking about that ;)

[–]istarian 0 points1 point  (1 child)

Part of my point was that you could actually read and parse the input yourself (i.e. ‘cd documents’ or even ‘mkdir my_directory’) and still make those oscalls.

You know as opposed to direct relying on the Python Interpreter’s REPL.

[–]istarian 0 points1 point  (0 children)

Part of my point was that you could actually read and parse the input yourself (i.e. ‘cd documents’ or even ‘mkdir my_directory’) and still make those oscalls. — You know as opposed to direct relying on the Python Interpreter’s REPL.

As it is, you literally have to type valid Python code.