Jump to Navigation

Me on Twitter

  • RT @wselman: I try to not to post too many articles about @firefox but this is the best article I've seen that explains how we are working… 5 years 47 weeks ago
  • RT @MarciRobin: I bought a car today, and the dealership had me check off — with a pen, on paper — that I’m not a robot. https://t.co/x6nJ6… 5 years 48 weeks ago
  • If you want to quickly unregister from #Yahoo #Oath 321 (!) trackers : open browser console (F12) and run `var t=0… https://t.co/qzHuvEXZT0 5 years 49 weeks ago
  • Avis aux connaisseurs ;-) https://t.co/4uEtnV5x2E 5 years 49 weeks ago
  • RT @tewoz: Encore un carnet bien rempli... au suivant !!! #sketchbook #sketchnote #sketch #illustration #happyscribing #scribing #moleskine… 5 years 49 weeks ago
  • Net neutrality. Last chance? https://t.co/nsFcZFQGI7 5 years 50 weeks ago
  • RT @clx_asso_fr: Fête des Libertés Numériques : Données personnelles et droits et libertés (...) https://t.co/HDCLbaj6Xo 5 years 50 weeks ago
  • RT @samuelberthelot: Atelier : Apprenons ensemble à nous déGAFAiser ! - Fête des Libertés Numériques https://t.co/yX5BxApirR via @nuzzel 5 years 50 weeks ago
  • @StackExchange just amazed me again https://t.co/t4PpnhdpY6 5 years 51 weeks ago
  • RT @Numerama: Victime d'un bug, Twitter vous recommande de changer votre mot de passe https://t.co/UlBlW5BzeJ https://t.co/EEfYsx0Oxb 5 years 51 weeks ago

Python versus Shell scripting : from experience

A quick "pros & cons" to choose between Python or Shell scripting, from what I've observed through the years.

This could probably apply to other high level script languages* vs shell.

* Like Ruby, but not like Perl, as it shares more with shells from my point of view, like unreadable syntax and execution speed.

Python vs Shell

Choose Python for :

  • its simple syntax : can be read even by non Python-speaking people. End users may not be scared to change scripts to fit their need.
  • portability : Python is actually more portable than shell because of ease of installation for any OS. Shell is theoretically portable but it's complicated to explain end users how to install the runtime (e.g. see cygwin). A Python script can be packaged into an executable program. There may be ways to bundle a script with the shell runtime.

Choose Shell for :

  • speed : except in case of bad code logic, shell scripts are usually a lot faster than Python's equivalents.
  • its ease to deal with external programs and system : shell's syntax is already made to test/pipe/chain easily existing programs, whereas Python requires some extra boilerplate. Shell also has built-in functions to deal directly with files and the system, whereas Python uses an object-oriented model, which may not be as handy.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • E-Mail addresses are hidden with reCAPTCHA Mailhide.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>. The supported tag styles are: <foo>, [foo].
  • Twitter-style #hashtags are linked to search.twitter.com.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.