Why indentation is use to denote block of code?

Discussion in 'Python' started by Peng Yu, Sep 13, 2009.

  1. Peng Yu

    Peng Yu Guest

    Hi,

    I want to understand why python use indentation to denote block of
    code. What are the advantages of it? Is there a style in python to
    denote a block of code the same as that of C++ (with '{}')?

    One disadvantage of using indentation to denote a block of code is
    that the runtime to automatically indent a python code would be about
    a few times more than the runtime to automatically indent a C++ code
    of the same length (both are in vim).

    Regards,
    Peng
     
    Peng Yu, Sep 13, 2009
    #1
    1. Advertising

  2. Peng Yu

    Sean DiZazzo Guest

    On Sep 13, 3:12 pm, Peng Yu <> wrote:
    > Hi,
    >
    > I want to understand why python use indentation to denote block of
    > code. What are the advantages of it? Is there a style in python to
    > denote a block of code the same as that of C++ (with '{}')?
    >
    > One disadvantage of using indentation to denote a block of code is
    > that the runtime to automatically indent a python code would be about
    > a few times more than the runtime to automatically indent a C++ code
    > of the same length (both are in vim).
    >
    > Regards,
    > Peng


    Try this:

    from __future__ import braces

    ~Sean
     
    Sean DiZazzo, Sep 13, 2009
    #2
    1. Advertising

  3. Peng Yu

    Sean DiZazzo Guest

    On Sep 13, 3:12 pm, Peng Yu <> wrote:
    > Hi,
    >
    > I want to understand why python use indentation to denote block of
    > code. What are the advantages of it? Is there a style in python to
    > denote a block of code the same as that of C++ (with '{}')?
    >
    > One disadvantage of using indentation to denote a block of code is
    > that the runtime to automatically indent a python code would be about
    > a few times more than the runtime to automatically indent a C++ code
    > of the same length (both are in vim).
    >
    > Regards,
    > Peng


    Looking at your other post regarding "strict mode", I have to
    comment. I think you are looking for a different language. What you
    are hoping to change about the language are some of the major things
    that make it a joy to program for me. Braces, static typing, no
    indentation... What's next? Would you like semicolons?

    I suggest you spend some time just programming it the way it was made
    to be programmed, and quit trying to turn it into Perl or any other
    language. If after a week or two, you don't like it, then move on.
    And save us the complaints.

    ~Sean
     
    Sean DiZazzo, Sep 13, 2009
    #3
  4. Peng Yu

    r Guest

    On Sep 13, 5:12 pm, Peng Yu <> wrote:
    > Hi,
    >
    > I want to understand why python use indentation to denote block of
    > code. What are the advantages of it? Is there a style in python to
    > denote a block of code the same as that of C++ (with '{}')?


    Easy! because Python is simplistic programming bliss!

    Indenting code makes the blocks easier to read and forcing this on
    Python programmers is a good thing. And as a side effect "dedent" can
    be used to find the end of a block. Some languages still use block
    ending notations like the redundant "end". I think they do this from
    an inability to break from old habits and fear of change.

    You will find Python to be a revolutionary language that does not
    confine itself to closed minded archaic redundancies and asinine
    design flaws. Pythons simplistic syntax, elegant coding structure, and
    beautifully intelligent design, encompass the traits that every twenty
    first century language should aspire to be.

    Right now you can think of yourself as the poor Neo, completely
    oblivious of the matrix(C) that blinds you to reality. You can think
    of Python as Morpheus, the one who shall open your eyes to the
    atrocities of C and other evil languages of who's names i shall not
    utter here. This should enlighten you a bit...

    http://tiny.cc/TheBlindingMatrixOfC
     
    r, Sep 13, 2009
    #4
  5. Peng Yu

    TerryP Guest

    On Sep 13, 10:12 pm, Peng Yu <> wrote:
    > Hi,
    >
    > I want to understand why python use indentation to denote block of
    > code. What are the advantages of it? Is there a style in python to
    > denote a block of code the same as that of C++ (with '{}')?
    >
    > One disadvantage of using indentation to denote a block of code is
    > that the runtime to automatically indent a python code would be about
    > a few times more than the runtime to automatically indent a C++ code
    > of the same length (both are in vim).
    >
    > Regards,
    > Peng


    Not to be omega-rude and disrespectful, but if you have to ask such a
    question -- you are either to stupid a programmer to warrant any
    intellectual response, or are just interested in wasting peoples
    bandwidth.

    The advantages and disadvantages of the white space thing, is
    generally self evident: which is likely by design in my opinion.

    --
    A fairly language independent programmer.
     
    TerryP, Sep 14, 2009
    #5
  6. Peng Yu

    Guest

    On 09/13/2009 10:43 PM, TerryP wrote:
    > On Sep 13, 10:12 pm, Peng Yu <> wrote:
    >> Hi,
    >>
    >> I want to understand why python use indentation to denote block of
    >> code. What are the advantages of it? Is there a style in python to
    >> denote a block of code the same as that of C++ (with '{}')?
    >>
    >> One disadvantage of using indentation to denote a block of code is
    >> that the runtime to automatically indent a python code would be about
    >> a few times more than the runtime to automatically indent a C++ code
    >> of the same length (both are in vim).

    >
    > Not to be omega-rude and disrespectful, but if you have to ask such a
    > question -- you are either to stupid a programmer to warrant any
    > intellectual response, or are just interested in wasting peoples
    > bandwidth.


    Not to be omega-rude and disrespectful either but if you think
    tradeoffs made in designing a language, such as the choice of
    indents or braces to denote blocks, are simple and obvious
    ones, then you are either a very stupid person, or are trying
    to vent your anger from the safety of a remote computer.
     
    , Sep 14, 2009
    #6
  7. On Sun, 13 Sep 2009 21:43:49 -0700 (PDT) TerryP <>
    wrote:

    > Not to be omega-rude and disrespectful, but if you have to ask such a
    > question -- you are either to stupid a programmer to warrant any
    > intellectual response, or are just interested in wasting peoples
    > bandwidth.
    >

    Wow, dude. Easy. There was absolutely no reason for this kind of
    statement. The OP is probably just used to a certain way of programming
    and has a hard time adjusting. Some people are that way, so why not cut
    them some slack.

    In general: How about we leave it at that? This is in the list of
    Frequently Asked Questions, and the point of that is that it does not
    become a frequently answered question. We can do better things than
    start attacking or defending syntax, can we?

    /W

    --
    INVALID? DE!
     
    Andreas Waldenburger, Sep 14, 2009
    #7
  8. Peng Yu

    TerryP Guest

    >
    > Not to be omega-rude and disrespectful either but if you think
    > tradeoffs made in designing a language, such as the choice of
    > indents or braces to denote blocks, are simple and obvious
    > ones, then you are either a very stupid person, or are trying
    > to vent your anger from the safety of a remote computer.


    I did not say the choice of, I said the advantage and disadvantage of;
    there is _quite a bit of difference_ between such statements. If I had
    said the former, I would agree with you, but as I said the latter,
    I'll remark thus: in use they become very apparent, to anyone whose
    used much of either style.

    Designing and using a language are different things.


    On Sep 14, 3:38 pm, Andreas Waldenburger <>
    wrote:
    > Wow, dude. Easy. There was absolutely no reason for this kind of
    > statement. The OP is probably just used to a certain way of programming
    > and has a hard time adjusting. Some people are that way, so why not cut
    > them some slack.
    >



    I'm not a person who believes in mincing words off the first date, so
    I apologize (OP included) if my choice of words were too harsh.
    There's no intention of attacking or defending anything, just of being
    concise!


    Two things I learned at an early age, a C programmer can write C in
    any language - and making Adam into Eve is probably a bad idea.
     
    TerryP, Sep 14, 2009
    #8
  9. Peng Yu

    Robert Kern Guest

    On 2009-09-14 12:42 PM, TerryP wrote:

    > I'm not a person who believes in mincing words off the first date, so
    > I apologize (OP included) if my choice of words were too harsh.
    > There's no intention of attacking or defending anything, just of being
    > concise!


    I would never have thought to describe your post as "concise". In fact, you
    seemed to go out of your way to abuse the OP with rhetorical flourishes and
    avoid giving any actual information. There are times when concise but
    informative responses can appear to be rude, but you can't hide deliberate abuse
    behind that excuse.

    > Two things I learned at an early age, a C programmer can write C in
    > any language - and making Adam into Eve is probably a bad idea.


    Adam can bloody well act like a decent human being without losing his manhood, I
    assure you.

    --
    Robert Kern

    "I have come to believe that the whole world is an enigma, a harmless enigma
    that is made terrible by our own mad attempt to interpret it as though it had
    an underlying truth."
    -- Umberto Eco
     
    Robert Kern, Sep 14, 2009
    #9
  10. Peng Yu

    r Guest

    On Sep 14, 5:20 pm, Ben Finney <> wrote:
    > TerryP <> writes:
    > > Not to be omega-rude and disrespectful, but if you have to ask such a
    > > question -- you are either to stupid a programmer to warrant any
    > > intellectual response, or are just interested in wasting peoples
    > > bandwidth.

    >
    > If you think this is “not to be rude and disrespectful”, you're not
    > reading what you write. Please refrain from personal insults like this.


    > Ben Finney


    Respectfully Ben (or anyone regular for that matter), when have you
    come to the aid of a noob when a "regular" on this group has shown
    disrespect? I have seen lots of disrespect flung downwards and nobody
    says a peep about it. Every time a small disagreement erupts the
    *plonking* or trolling begins. I can't see why some get so emotional
    and let disagreement turn to hate filled rage. Actually since i have
    been *plonked* my experiences here have been much better. Maybe one
    day the *plonkers* will return, but if not, oh well!

    The OP obviously did not ponder the deeps of why Python uses indention
    for blocks before posting. I will admit TerryP's language could offend
    touchy people, but i have seen much worse on this list from some very
    well known regulars!

    This group is not the shining jewel of friendliness i wish it were. I
    have been here for about 1.5 years and still feel i must watch my back
    constantly. Too many people let little disagreement harbor
    resentments. I have no time for hating this person or that person
    because i do not agree with his or her politics or whatever. I may
    exchange heated debate with them one minute and share a cold beer the
    next. I think some of you need to follow this model.

    A Usenet group is for learning and participating. No one should ever
    feel intimidated to post comments because he or she may get bullied. I
    find i learn much more about a subject when i get involved and share
    my opinions. Sometimes i might be completely wrong, and get a wee bit
    embarrassed, but what better way to learn than that!

    I think Terrp's post is not a case of bulling, more a case of one or
    two poor word choices. TerryP's post is actually completely factual,
    albeit just a wee bit *too* colorful. ;-)

    everybody just relax a bit!
     
    r, Sep 15, 2009
    #10
    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. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,222
    Smokey Grindel
    Dec 2, 2006
  2. morrell
    Replies:
    1
    Views:
    1,000
    roy axenov
    Oct 10, 2006
  3. John Fly
    Replies:
    11
    Views:
    490
    Phlip
    Feb 25, 2006
  4. Chris Rebert
    Replies:
    4
    Views:
    335
    Terry Reedy
    Sep 14, 2009
  5. Jesse B.
    Replies:
    2
    Views:
    220
    Josh Cheek
    Mar 27, 2010
Loading...

Share This Page