Jump to Navigation

Me on Twitter

  • "How standards proliferate" - probably old but makes me laugh since it's #sotrue https://t.co/6ygxIBf7Lh #xkcd 2 weeks 2 days ago
  • RT @Numerama: Enquête : comment les apps Figaro, L'Équipe ou Closer participent au pistage de 10 millions de Français - https://t.co/GBcnT0… 4 weeks 1 day ago
  • When industry meets open source... https://t.co/uJbhJhZFyK Subscribe here https://t.co/NAOLqb4AL9 4 weeks 5 days ago
  • @Fyrd Do you know of a tool to list features used on a given website in order to obtain the minimum browsers requirements to make it work ? 24 weeks 5 hours ago
  • Quelqu'un aurait une place disponible pour #devoxx pour un collègue ? 31 weeks 1 day ago
  • Favorite tool of the day : https://t.co/1wGUhgh5rc @AtomEditor It also displays @PlantUML diagrams ! 39 weeks 1 day ago
  • With typeset you can do weird things like : myvar=hello echo $myvar # prints 'HELLO' in caps https://t.co/bLNDQrmokn 42 weeks 1 day ago
  • I've just stared at a 22mn intro to this #game ! Zachtronics | TIS-100 - https://t.co/36Tlp5HBB6 43 weeks 2 days ago
  • RT @nicoespeon: Six Tiny But Awesome #ES6 Features by @davidwalshblog https://t.co/kYNcYMrhVe 44 weeks 3 days ago
  • If u ever build Jenkins jobs with maven use the following delimiters 2 avoid variable clash : @maven_var@ + $jenkins_var vs ${var} for both 48 weeks 1 day 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.