Re: How's ruby compare to it older brother python

From: Steve Lamb (grey_at_despair.dmiyu.org)
Date: 04/26/04


Date: Mon, 26 Apr 2004 20:22:26 GMT

On 2004-04-26, Phil Tomson <ptkwt@aracnet.com> wrote:
> Well, there is one big difference syntactically: Python uses indentation
> as syntax and Ruby doesn't. Personally I don't prefer Python's
> 'indentation-as-syntax' since it means that syntactically significant
> pieces of my code are invisible and if the tab settings in my editor are
> not the same as yours it can make it difficult to share code (or even

    Why is this trotted out every time? I guarentee that my code will look
perfectly fine in your editor. I cannot guarentee the reverse as while you
might have a penchant for tabs I do not. I am not alone in that regard.
Here's a snippet from the Python style guide:

Tabs or Spaces?
Never mix tabs and spaces. The most popular way of indenting Python is with
spaces only. The second-most popular way is with tabs only. Code indented with
a mixture of tabs and spaces should be converted to using spaces exclusively.
(In Emacs, select the whole buffer and hit ESC-x untabify.) When invoking the
python command line interpreter with the -t option, it issues warnings about
code that illegally mixes tabs and spaces. When using -tt these warnings
become errors. These options are highly recommended!

    So unless your tab setting is 0 syntactically significant pieces of code
should always have a different indention level. Furthermore if the
program(mers) follow the style guide then that is a non-issue.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------


Relevant Pages

  • Re: Tabs versus Spaces in Source Code
    ... Python works out the indentation level ... it uses is designed to accommodate people who mix tabs and spaces ...
    (comp.lang.python)
  • Re: #include <math.h>
    ... >> Python accepts both tabs and spaces as indentation. ... But Python's indentation rules follow the informal format of all other ... Emacs even does it ...
    (comp.lang.c)
  • Re: OT: Why is C so popular?
    ... In every case that still explans why python code found on the net ... Use the default of Emacs Python-mode: 4 spaces for one indentation level. ... 8-space tabs. ... > the Python language definition that tabstop is at 8 spaces, ...
    (Debian-User)
  • Re: Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever o
    ... >> In Python, newlines are significant, except within lists, tuples, etc. ... > spaces and tabs in a single file as long as you use an 8-space convention. ... > is default in almost every editor, though), the indentation can LOOK ... a number of popular editors leave in the file. ...
    (comp.lang.python)
  • Re: OT - trivial programming language
    ... |> That makes two votes for Python. ... If you think indentation doesn't matter, join any C, C++ or Java ... keyboard engraved with the label 'Tab' is pressed. ... If you use vim, set the following options. ...
    (Debian-User)