Why indentation is use to denote block of code?

P

Peng Yu

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
 
S

Sean DiZazzo

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
 
S

Sean DiZazzo

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

r

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
 
T

TerryP

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.
 
R

rurpy

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.
 
A

Andreas Waldenburger

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
 
T

TerryP

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.


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.
 
R

Robert Kern

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

r

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top