X-Received: by 10.224.18.199 with SMTP id x7mr10267591qaa.1.1361849874856; Mon, 25 Feb 2013 19:37:54 -0800 (PST) X-Received: by 10.49.85.233 with SMTP id k9mr1199168qez.41.1361849874835; Mon, 25 Feb 2013 19:37:54 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!dd2no3041696qab.0!news-out.google.com!t2ni671qaj.0!nntp.google.com!dd2no3041690qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Mon, 25 Feb 2013 19:37:54 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=124.168.202.14; posting-account=ZAg6xAoAAAAmY8bBi3VzYjWntm8Ct1P8 NNTP-Posting-Host: 124.168.202.14 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Python Newbie From: Nick Mellor Injection-Date: Tue, 26 Feb 2013 03:37:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.python:39925 Hi Piterr, It's interesting how strong our habits are, isn't it? It's most likely you'= ve just got a bit of culture shock. I've used C# quite a bit as well as Python. I like them both. What I like about Python is how it manages to be clear and terse at the sam= e time. if (flag=3D=3D1) { code } has quite a bit of redundancy in it (C or C#.) In Python: if flag: code is a good shorthand that matches any non-zero value. Gone are the brackets = and the braces and the meaning is crystal clear. In the middle of a complex piece of code this clarity of syntax is fantasti= c for anyone reading the code-- so long as they know how Python works. You may discover as you continue with Python that there is actually quite a= lot of freedom about how you use white space. Python doesn't much care *ho= w* much you indent, just that you're consistent within the block: if flag: # do something # do something else # continue coding after the if stmt is equivalent to if flag: # do something # do something else # continue coding after the if stmt You're also allowed to break a line inside brackets, braces etc and use any= indenting you like: if flag: [o.process(i % 3 + w) for i, o, w in enumerate(zip(objects, words)) ] # do something else # this is after the if block The following is a good thread about "implied line continuation" (i.e. wher= e line breaks and free indentation are allowed inside braces, square bracke= ts or round brackets.) http://stackoverflow.com/questions/53162/how-can-i-do-a-line-break-line-con= tinuation-in-python See also the Python style guide: http://www.python.org/dev/peps/pep-0008/ There's also explicit line continuation, rather like Visual Basic: if c + \ 256 * \ (d + 256 * e) > 69427: # do something # do something else # then leave the if block Again, the line continuation doesn't mind what indent you use after it. In this case you could put brackets around the expression and use implied l= ine continuation: if (c + 256 * (d + 256 * e)) > 69427: # do something # do something else # then leave the if block This is the preferred method according to the Python style guide. I hope you manage to give Python (and your job) a little longer to charm yo= u :-) Cheers, Nick On Friday, 22 February 2013 08:26:41 UTC+11, Piterrr wrote: > Hi folks. >=20 > I am a long time C sharp dev, just learning Python now due to job require= ments. My initial impression is that Python has got to be the most ambiguou= s 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? In addition, code is difficult to read because = you cannot lay it out in easily discernable blocks. For example, I always t= end 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. What is even more f= rustrating is that Python is inconsistent with its syntax. For example, whe= n I write "if (myVariable !=3D 0):" then this is OK but "for (i in intAry):= " results in syntax error. Apparently Python has problems with my use of pa= rentheses. How retarded. I think I will rather find another job than eat my= nerves with Python. >=20 > Any comments on this before I quit my job?