Loading ...
Sorry, an error occurred while loading the content.

29410Re: % matching for Python

Expand Messages
  • Alejandro López-Valencia
    Aug 6, 2002
    • 0 Attachment
      On Tuesday, August 06, 2002 10:56 AM,
      David Brown <vim@...> about the unbearable subtleness of being wrote:

      >
      > That's why the PEP8 specifies to use spaces instead of tabs. However,
      > Python was designed to accept tabs as equivalent to spaces, but
      > _ALWAYS_ with a tabstop set to 8. It is the setting of the tabstop
      > to a value of other than 8 (common for non *nix editors) that can
      > bite. Even with the tabstop set wrong, often you get lucky and
      > things just work, especially if indenting is only done with tabs.
      >
      > My main reaction was to the suggestion to set the tabstop to 4 for
      > python code. This is going to bite someone someday. The default for
      > python, according to PEP8 should be
      >
      > shiftwidth=4
      > tabstop=8
      > expandtab

      The conflict you point out is a consequence of making shiftwidth different
      to tabstop, now, that, is asking for real trouble. :)

      I prefer

      shiftwidth=4
      tabstop=4
      expandtab

      because it works and is portable at the same time. That is, it works fine
      with new files and with files that are properly indented, that is, where the
      creator has either used spaces (and one can therefore figure out his/her
      perverted idea of how many spaces is an indent and adjust accordingly) or
      uses one tab per indention level *and* no space-tabs mixing for indention.

      As well, if one chooses to forgo the expandtab setting and use tabs instead
      of spaces, the file is still readable under a text editor that only manages
      8 space tabstops (because most of those can't change shiftwidth neither);
      and the python bytecode compiler will do the right thing as well.
    • Show all 16 messages in this topic