Python Newbie

Ian Kelly ian.g.kelly at gmail.com
Thu Feb 21 22:54:04 CET 2013


On Thu, Feb 21, 2013 at 2:26 PM, Piterrr <piterrr.dolinski at gmail.com> wrote:
> I am a long time C sharp dev, just learning Python now due to job requirements. My initial impression is that Python has got to be the most ambiguous and vague language I have seen to date. I have major issues with the fact that white space matters. How do you deal with this? For example, you open a source file in different editors and the indentation levels change even though i only have spaces, no tabs (compare Windows Notepad and Notepad++). Which editor do you trust?

I have never had this problem (although I don't use either of those
editors either).  Are you sure you don't have any tabs in there?

> In addition, code is difficult to read because you cannot lay it out in easily discernable blocks. For example, I always tend to indent a full 'if' statement block so that it is easier to see where the if block starts and ends. Can't do that in Python.

I don't understand what it is that you want to do but can't.  Can you
give an example?  The whole point of making indentation matter in
Python is to *force* the programmer to lay out their blocks in a
consistent and easily discernible manner.

> What is even more frustrating is that Python is inconsistent with its syntax. For example, when I write "if (myVariable != 0):" then this is OK but "for (i in intAry):" results in syntax error. Apparently Python has problems with my use of parentheses.

The former works because the if statement only takes one expression,
and the parentheses are interpreted as part of that expression, not
part of the syntax for the if.  The for statement requires both a
variable name and an expression, distinguished by syntax, which again
includes no parentheses.  You could surround just the expression part
in parentheses if you like -- "for i in (intAry):" -- but it looks
pretty weird if you ask me.

I don't know why you should expect to be able to add parentheses to
arbitrary syntax and have it just work.  It strikes me as being like
trying to declare a variable as "int (x=3);" in C# (which I haven't
tested, but I doubt that is valid syntax).



More information about the Python-list mailing list