R
Rui Maciel
Mitya said:Looks very unclear and confusing to me. Whether it's C# or ruby or
anything else, most devs don't indent like that;
The Go programming language makes that style mandatory.
Rui Maciel
Mitya said:Looks very unclear and confusing to me. Whether it's C# or ruby or
anything else, most devs don't indent like that;
The Go programming language makes that style mandatory.
Chris said:The Go programming language makes that style mandatory.
[citation needed]
What do you mean by "that style"? The OP's style with the 'if'
indented? I just checked out golang.org for examples, and they're
written in OTBS.
Chris said:Mitya Sirenef wrote:
Looks very unclear and confusing to me. Whether it's C# or ruby or
anything else, most devs don't indent like that;
The Go programming language makes that style mandatory.
[citation needed]
What do you mean by "that style"? The OP's style with the 'if'
indented? I just checked out golang.org for examples, and they're
written in OTBS.
Read Mitya Sirenef's post, specifically the bit I've replied to.
Oooh, this is making my head spin. Are you saying that the OP'sDo you believe that post was talking about the indentation of the keywordRui Maciel said:Chris said:Mitya Sirenef wrote:
Looks very unclear and confusing to me. Whether it's C# or ruby or
anything else, most devs don't indent like that;
The Go programming language makes that style mandatory.
[citation needed]
What do you mean by "that style"? The OP's style with the 'if'
indented? I just checked out golang.org for examples, and they're
written in OTBS.
Read Mitya Sirenef's post, specifically the bit I've replied to.
'if' relative to the statements in the same block, or did you think it was
talking about the placement of the opening brace on the same line as the
`if` statement?
I believe that Mitya was talking about the former but that you assumed the
latter.
Oooh, this is making my head spin. Are you saying that the OP's question
about proper indentation has resulted in an incorrectly answered post due to
poor indentation of a reference to the indentation of another reference?
Thanks to everyone for all the posts, some friendly some not. I read all of them with genuine interest.
So I am continuing to learn Python, here are my new observations for yourconsideration.
There seems to be a "heated" argument about Python's apparently intentional ambiguity in conditional statements. Specifically, the issue is, is it more appropriate to write (as an example)
if (some statement): # short form
rather than
if (some statement == true): # long form
Some 50(?) years ago, C was designed so that everything other than 0 evaluated to true and was false otherwise. Fast forward to recent memory, when C# was designed, Microsoft claims they reviewed all the features of C, C++ and Java, pulled the best features from each of these languages and designed a new language that would help minimize the potential for planting bugs.
Say what you want about MS inventions, but my experience is that to require the long form notation was a good decision. For me the fact that the short notation is legal in Python is a stepback in language design. Python inventors, when creating what is after all considered a contemporary language,should have known better. Call me psychopath if you will (have seen this in one post), but I shall continue to use the aforementioned long form as I always have, and no Python is going to change that.
Today I learned the hard way that all function parameters in Python are passed by reference (meaning whatever happens to them inside a function, newvalues are always passed to caller). Not good. I got caught up on this. Tocombat the mostly unwanted behavior, inside a function I have to reassign variables intended to be local to new variables. A pain. Can anyone offer ONE reason why Python was designed that way?
Out of curiosity, does anyone have any idea why function declarations arepreceded by the keyword "def" rather than something more intuitive like "function" or at least "func", perhaps?
Does anyone know what the benefit of writing the cryptic "elif" to mean "else if" is? Curiously, the default statement in an if/else chain is preceded by "else" and not "el".
Someone said I am too narrow-sited appreciating C# and not open to alternate approaches to language design. Well if that someone says "def" is better than "function" and "elif" is better than "else if", then dare I say, youare obsessed with Python!
So far I am getting the impression that Python is a toy language of some kind (similar to Basic of the early 80's), not really suitable for serious work. The only difference between these languages (admittedly, a serious one) is the existence of extensive libraries. Otherwise there would be no good reason for Python to exist. Nevertheless, it does exist and I have to learn it. As long as someone is paying for my time, that's OK with me.
There seems to be a "heated" argument about Python's apparently intentional ambiguity in conditional statements. Specifically, the issue is, is it more appropriate to write (as an example)
if (some statement): # short form
rather than
if (some statement == true): # long form
Some 50(?) years ago, C was designed so that everything other than 0 evaluated to true and was false otherwise. Fast forward to recent memory, when C# was designed, Microsoft claims they reviewed all the features of C, C++ and Java, pulled the best features from each of these languages and designed a new language that would help minimize the potential for planting bugs. Say what you want about MS inventions, but my experience is that to requirethe long form notation was a good decision. For me the fact that the shortnotation is legal in Python is a stepback in language design. Python inventors, when creating what is after all considered a contemporary language, should have known better. Call me psychopath if you will (have seen this in one post), but I shall continue to use the aforementioned long form as I always have, and no Python is going to change that.
Today I learned the hard way that all function parameters in Python are passed by reference (meaning whatever happens to them inside a function, newvalues are always passed to caller).
Not good. I got caught up on this. To combat the mostly unwanted behavior, inside a function I have to reassign variables intended to be local to new variables.
A pain. Can anyone offer ONE reason why Python was designed that way?
Out of curiosity, does anyone have any idea why function declarations arepreceded by the keyword "def" rather than something more intuitive like "function" or at least "func", perhaps?
Does anyone know what the benefit of writing the cryptic "elif" to mean "else if" is? Curiously, the default statement in an if/else chain is preceded by "else" and not "el".
Or else golang.org is wrong. That's certainly possible, but you know
what they say about extraordinary claims.
I think this obvious shortcomming is the main reason that, for example, when x holds the value of 5, x is considered to be "true". You see, I have to maintain Python files (ubuntu server scripts) which are 2000 lines long, all sequential code, no functions. While the person who wrote them should be shot , the fact that there is inherent ambiguity with value, none, null0, you name it, in conditional statements is not helping me understand thecode, and this adds to my frustration.
Btw, there are still languages with no boolean type today, MySQL for one.This creates big efficiency problems when fetching data from the database into a C# program - what should be a bool is fetched as an 8-byte integer! But that's a different story. I shut up now.
They must be true?
"Extraordinary claims are always true" would be an extraordinary claim,
and therefore true. I learned this from Weekly World News, the world's
only reliable newspaper.
http://weeklyworldnews.com/headlines/44680/pteranodon-terrifies-wyoming-town/
The Go programming language makes that style mandatory.
Rui Maciel
Thanks to everyone for all the posts, some friendly some not. I read all of them with genuine interest.
So I am continuing to learn Python, here are my new observations for your consideration.
There seems to be a "heated" argument about Python's apparently
intentional ambiguity in conditional statements. Specifically, the
issue is, is it more appropriate to write (as an example)
if (some statement): # short form
rather than
if (some statement == true): # long form
Some 50(?) years ago, C was designed so that everything other than 0
evaluated to true and was false otherwise. Fast forward to recent
memory, when C# was designed, Microsoft claims they reviewed all the
features of C, C++ and Java, pulled the best features from each of
these languages and designed a new language that would help minimize
the potential for planting bugs. Say what you want about MS
inventions, but my experience is that to require the long form
notation was a good decision. For me the fact that the short notation
is legal in Python is a stepback in language design. Python inventors,
when creating what is after all considered a contemporary language,
should have known better. Call me psychopath if you will (have seen
this in one post), but I shall continue to use the aforementioned long
form as I always have, and no Python is going to change that.
Today I learned the hard way that all function parameters in Python
are passed by reference (meaning whatever happens to them inside a
function, new values are always passed to caller). Not good. I got
caught up on this. To combat the mostly unwanted behavior, inside a
function I have to reassign variables intended to be local to new
variables. A pain. Can anyone offer ONE reason why Python was designed
that way?
Out of curiosity, does anyone have any idea why function declarations
are preceded by the keyword "def" rather than something more intuitive
like "function" or at least "func", perhaps?
Does anyone know what the benefit of writing the cryptic "elif" to
mean "else if" is? Curiously, the default statement in an if/else
chain is preceded by "else" and not "el".
Someone said I am too narrow-sited appreciating C# and not open to
alternate approaches to language design. Well if that someone says
"def" is better than "function" and "elif" is better than "else if",
then dare I say, you are obsessed with Python!
So far I am getting the impression that Python is a toy language of
some kind (similar to Basic of the early 80's), not really suitable
for serious work. The only difference between these languages
(admittedly, a serious one) is the existence of extensive libraries.
Otherwise there would be no good reason for Python to exist.
Nevertheless, it does exist and I have to learn it. As long as someone
is paying for my time, that's OK with me.
It's been used for many important projects by a huge number of big
companies:
http://www.python.org/about/success/
Unlike Java and C#, it's not backed by a marketing effort of a large
company, so its success is entirely due to its value.
+1 QOTW
Well said. While Sun (now Oracle) have spent millions marketing Java, and
Microsoft done the same for C#, Python has got where it is almost
entirely on merit and word-of-mouth.
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.