10

Recently I was looking at python's shutil and subprocess etc... And I started wondering: wouldn't it be ok to use python instead of e.g. bash?

What am I missing?

xtofl
  • 334
  • 2
  • 10

1 Answers1

12

Convenience of syntax, mostly.

In python, running a process requires subprocess.call(...); renaming a file shutil.move(), etc. Bash syntax is much more direct for those tasks.

Yes, Python is a great language, but the explicit syntax to execute (for bash) simple tasks is going to get in the way of doing day-to-day work real fast.

Martijn Pieters
  • 14,499
  • 10
  • 57
  • 58
  • 4
    http://amoffat.github.com/sh/ – Ismail Badawi Jan 09 '13 at 18:50
  • @isbadawi: exactly; adding a powerful module helps improve the convience levels of course! But if we are looking at *just* python, then those same tasks are going to be (a lot) more cumbersome. – Martijn Pieters Jan 09 '13 at 18:53
  • Looking just at "just python" (which I presume is core language + stdlib to you) is useless IMHO, in that it doesn't match how the language is actually used. –  Jan 09 '13 at 19:02
  • @delnan: sure, but it is a major reason why we are not all using Python as our default shell, I'd say. – Martijn Pieters Jan 09 '13 at 19:04
  • @isbadawi Even with that package, it's still rather verbose/cluttered compared to bash... – Izkata Jan 09 '13 at 19:14
  • 3
    @Izkata: verbose/cluttered is a relative thing. I find doing almost *any* type of serious programming in bash to be like getting a root canal without anesthesia. (And I say that having been at a shell prompt since 1980.) Bash still is forking subprocesses just like Python, so it doesn't seem to have any inherent advantage other than 3 decades of inertia. – Peter Rowell Jan 10 '13 at 06:45
  • 5
    Also see [Why are scripting languages (e.g. Perl, Python, Ruby) not suitable as shell languages?](http://stackoverflow.com/a/3640403/2988) on StackOverflow. – Jörg W Mittag Jan 10 '13 at 09:36
  • 3
    Here's the latest Internet Archive of this question: [Why are scripting languages (e.g. Perl, Python, Ruby) not suitable as shell languages?](https://web.archive.org/web/20140528035940/http://stackoverflow.com/questions/3637668/why-are-scripting-languages-e-g-perl-python-ruby-not-suitable-as-shell-lang) – Blaz Sep 08 '15 at 14:04