Jump to Navigation

Me on Twitter

  • @alexlewando bon courage pour la fin ;-) #forgecamp 11 years 46 weeks ago
  • After spending the morning on android signing keys, I see green robots everywhere! Now it's becoming serious..! 11 years 46 weeks ago
  • @alexlewando Tu es dans quelle équipe ? 11 years 46 weeks ago
  • favorable user feedback is really the best reward http://t.co/1BF1IGUF 11 years 47 weeks ago
  • 1st #android app, 2nd release and so many hours for such a simple thing : https://t.co/OH0Wb4H6. Now back to #dataconnexions ! 11 years 47 weeks ago
  • quand je fais une mise en prod http://t.co/aZ66rUtG http://t.co/69Dh79sx #lesjoiesducode 11 years 47 weeks ago
  • You know that you got a good password when you cannot recover it yourself 11 years 48 weeks ago
  • Checking out tutorials @DataStax http://t.co/QOHSIUjj while waiting for yesterday @pcmanus slides or video... 11 years 48 weeks ago
  • @pcmanus hello peut-on avoir les slides d'hier ? 11 years 48 weeks ago
  • Very nice talk about #cassandra by @pcmanus . Makes it easy to understand the product pros and cons 11 years 48 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.