Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Why indentation is use to denote block of code? (http://www.velocityreviews.com/forums/t698162-why-indentation-is-use-to-denote-block-of-code.html)

Peng Yu 09-13-2009 10:12 PM

Why indentation is use to denote block of code?
 
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

Sean DiZazzo 09-13-2009 10:17 PM

Re: Why indentation is use to denote block of code?
 
On Sep 13, 3:12*pm, Peng Yu <pengyu...@gmail.com> 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 09-13-2009 10:42 PM

Re: Why indentation is use to denote block of code?
 
On Sep 13, 3:12*pm, Peng Yu <pengyu...@gmail.com> 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

r 09-13-2009 10:57 PM

Re: Why indentation is use to denote block of code?
 
On Sep 13, 5:12*pm, Peng Yu <pengyu...@gmail.com> 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

TerryP 09-14-2009 04:43 AM

Re: Why indentation is use to denote block of code?
 
On Sep 13, 10:12*pm, Peng Yu <pengyu...@gmail.com> 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.

rurpy@yahoo.com 09-14-2009 02:29 PM

Re: Why indentation is use to denote block of code?
 
On 09/13/2009 10:43 PM, TerryP wrote:
> On Sep 13, 10:12 pm, Peng Yu <pengyu...@gmail.com> 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.

Andreas Waldenburger 09-14-2009 03:38 PM

Re: Why indentation is use to denote block of code?
 
On Sun, 13 Sep 2009 21:43:49 -0700 (PDT) TerryP <bigboss1964@gmail.com>
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!


TerryP 09-14-2009 05:42 PM

Re: Why indentation is use to denote block of code?
 
>
> 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 <use...@geekmail.INVALID>
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.

Robert Kern 09-14-2009 06:14 PM

Re: Why indentation is use to denote block of code?
 
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


r 09-14-2009 11:00 PM

Re: Why indentation is use to denote block of code?
 
On Sep 14, 5:20*pm, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> TerryP <bigboss1...@gmail.com> 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!



All times are GMT. The time now is 12:15 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.