Re: Misuse of <tab>

Discussion in 'Python' started by Michael Sampson, Jul 30, 2003.

  1. How does the IDLE that comes with the latest release of python handle this?
    When it automaticly indents does it do it with spaces or tabs? If you hit
    tab in the IDLE will it just put 5 spaces in for you?




    "Gisle Vanem" <> wrote in message
    news:3f27f0e3$...
    > I'm a .py newbie and fascinated by the simplicity of formatting.
    > No need for {} as in Perl etc. But the misuse of <tab> that many
    > .py writers do makes it hard to understand how a script operates.
    >
    > E.g.
    >
    > def main():
    > terminate = 0
    > def foo():
    > line = sys.stdin.readline()
    > <tab> try:
    > bar()
    > except:
    > terminate = 1
    >
    > main()
    >
    > Now, with an editor with different tab-settings it's difficult to see

    where
    > the try statement belongs. In 'def main()' or in 'def foo()' ?
    > I'm confused, please enlighten me.
    >
    > --gv
    >
    >
     
    Michael Sampson, Jul 30, 2003
    #1
    1. Advertising

  2. On Wednesday 30 July 2003 13:20, Michael Sampson wrote:
    > How does the IDLE that comes with the latest release of python handle this?
    > When it automaticly indents does it do it with spaces or tabs? If you hit
    > tab in the IDLE will it just put 5 spaces in for you?
    >


    thou shalt always use even numbered indents.

    Or to paraphrase Monty Python:

    Thou shalt count to 4, 4 being the sacred number. Thou shalt not count 3 and
    5 is right out.
     
    Sean 'Shaleh' Perry, Jul 31, 2003
    #2
    1. Advertising

  3. Michael Sampson

    Ben Finney Guest

    On Wed, 30 Jul 2003 18:20:51 -0700, Sean 'Shaleh' Perry wrote:
    > thou shalt always use even numbered indents.


    More accurately, thou shalt always use even, factor-of-8 indents.
    (Making 2 and 4 the only valid indent sizes.)

    Ironically, this has its origins in the standard literal tab stop being
    8 (which number thou shalt not alter). Using factor-of-8 indent sizes
    means that every literal tab stop falls on an indent column. The irony
    comes from the deprecation of using literal tabs for indent at all :)

    --
    \ "I put instant coffee in a microwave oven and almost went back |
    `\ in time." -- Steven Wright |
    _o__) |
    Ben Finney <http://bignose.squidly.org/>
     
    Ben Finney, Jul 31, 2003
    #3
  4. On Wed, 30 Jul 2003 15:20:46 -0500, "Michael Sampson"
    <> wrote:

    >How does the IDLE that comes with the latest release of python handle this?
    >When it automaticly indents does it do it with spaces or tabs? If you hit
    >tab in the IDLE will it just put 5 spaces in for you?
    >


    IDLE 1.0 (from Python 2.3) has a pretty configuration dialog, accessed
    via Options|Configure IDLE, which lets you define its behaviour - do
    you want it to insert tabs as tabs or spaces, and how many spaces do
    you want, the default seeming to be converting a tab to 4 spaces.

    And, as others have said, DON'T use 5.



    --Christopher
     
    Christopher Koppler, Jul 31, 2003
    #4
  5. Gerhard Häring <> writes:

    > Christopher Koppler wrote:
    >> [tab settings]
    >> And, as others have said, DON'T use 5.

    >
    > I'd still like to hear a reason for this.
    >


    See PEP 8, Style Guide for Python Code: Consistency.

    Thomas
     
    Thomas Heller, Jul 31, 2003
    #5
  6. Michael Sampson

    Ben Finney Guest

    On Thu, 31 Jul 2003 13:03:15 +0200, Gerhard Häring wrote:
    > Christopher Koppler wrote:
    >> [tab settings]
    >> And, as others have said, DON'T use 5.

    >
    > I'd still like to hear a reason for this.


    <http://groups.google.com/groups?selm=slrnbih09e.vpm.bignose-hates-spam%40iris.polar.local>

    --
    \ "During the Middle Ages, probably one of the biggest mistakes |
    `\ was not putting on your armor because you were 'just going down |
    _o__) to the corner.'" -- Jack Handey |
    Ben Finney <http://bignose.squidly.org/>
     
    Ben Finney, Jul 31, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon North
    Replies:
    0
    Views:
    367
    Simon North
    Aug 5, 2004
  2. Peter Flynn
    Replies:
    2
    Views:
    440
    Peter Flynn
    Aug 9, 2004
  3. Michael Laplante

    Page won't validate -- misuse of A element?

    Michael Laplante, May 18, 2006, in forum: HTML
    Replies:
    3
    Views:
    477
    Jonathan N. Little
    May 18, 2006
  4. John Roth

    Re: Misuse of <tab>

    John Roth, Jul 30, 2003, in forum: Python
    Replies:
    8
    Views:
    378
    Robin Munn
    Aug 12, 2003
  5. naive misuse?

    , Aug 28, 2006, in forum: Python
    Replies:
    3
    Views:
    345
    Simon Forman
    Aug 29, 2006
Loading...

Share This Page