Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'python,': 0.02; 'syntax': 0.03; 'subject:Python': 0.05; 'preference': 0.05; 'perl,': 0.07; 'python': 0.09; '"if': 0.09; '22,': 0.09; 'brace': 0.09; 'braces': 0.09; 'eat': 0.09; 'instance.': 0.09; 'it;': 0.09; 'languages:': 0.09; 'other,': 0.09; 'url:faqs': 0.09; 'programmer': 0.11; 'language': 0.14; 'java,': 0.15; 'languages.': 0.15; 'weird': 0.15; '(just': 0.16; 'after,': 0.16; 'c/c++,': 0.16; "can't.": 0.16; 'expressions,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'helps.': 0.16; 'indent': 0.16; 'parentheses': 0.16; 'semicolon': 0.16; 'sharp': 0.16; 'statements,': 0.16; 'syntax.': 0.16; 'tabs': 0.16; 'url:catb': 0.16; 'url:hacker-howto': 0.16; 'wrote:': 0.17; 'everyone,': 0.17; 'tend': 0.17; 'code,': 0.18; 'windows': 0.19; 'feb': 0.19; 'code.': 0.20; 'addition,': 0.21; 'error.': 0.21; 'not,': 0.21; 'option.': 0.22; 'work,': 0.22; "python's": 0.23; 'raymond': 0.23; 'statement': 0.23; 'this:': 0.23; "haven't": 0.23; 'header:In- Reply-To:1': 0.25; 'common': 0.26; 'url:wiki': 0.26; '[1]': 0.27; 'am,': 0.27; 'separate': 0.27; 'question': 0.27; '(as': 0.27; 'converting': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'lines': 0.28; 'this?': 0.28; 'received:209.85.212': 0.28; 'initial': 0.28; 'represent': 0.28; 'trouble': 0.28; 'run': 0.28; 'editors': 0.29; 'forces': 0.29; 'indentation': 0.29; 'loop,': 0.29; 'omitted': 0.29; 'url:wikipedia': 0.29; 'starts': 0.29; 'source': 0.29; "i'm": 0.29; 'fri,': 0.30; 'keyword': 0.30; 'standards': 0.30; 'basic': 0.30; 'code': 0.31; 'file': 0.32; 'comments': 0.33; 'date.': 0.33; 'impression': 0.33; 'programming,': 0.33; 'to:addr:python-list': 0.33; '(with': 0.33; 'another': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'eric': 0.35; 'involving': 0.35; 'open': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'something': 0.35; 'next': 0.35; 'really': 0.36; 'but': 0.36; 'url:org': 0.36; 'anything': 0.36; 'problems': 0.36; 'editor': 0.37; 'does': 0.37; 'two': 0.37; 'rather': 0.37; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'comment': 0.38; 'easier': 0.38; 'fact': 0.38; 'mean': 0.38; 'some': 0.38; 'things': 0.38; 'sure': 0.38; 'url:en': 0.38; "you'll": 0.62; 'different': 0.63; 'more': 0.63; 'results': 0.65; 'learned': 0.65; 'skill': 0.65; 'due': 0.66; 'market': 0.66; 'levels': 0.66; 'teach': 0.69; 'guides': 0.71; '2013': 0.84; 'actually,': 0.84; 'contented': 0.84; 'dialect': 0.84; 'differences,': 0.84; 'embrace': 0.84; 'everything.': 0.84; 'matters.': 0.84; 'miffed': 0.84; 'nerves': 0.84; 'notepad,': 0.84; 'one).': 0.84; 'frustrating': 0.91; 'habit': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=MdpcA+LzI02mukZPtyIlaghptzu6+kqF8N12K9WbIJI=; b=MmfW9FVgOGKy7lVjnrlJ/ce0jk5QcFNC1KLcf0oUyFXtMO9zYxNOLB/7keP32U9yxp QmXaSgUjqPTIwt/lRPvaE+++fzqehlKwu00ped9T1SW9MEHUJ2zs0DuVQGAUFCx12Qca SK5rNOc3NpGIohnOFdO6mVEOnnHgVQqk//lbjqADwhM84/3Kk9px+GAZ5oqZ8fATb1zS N/bZ/7qd+ZEIg2lb+6uCUo5IO7Gn470K8OHAUgkQ4R6zjdOnMaf0qSKZUWn9qSa0lr0x 9zmvg3kHHFwQ0jMfFXxRfEBc3gwSoBYfakubanpAjq2Ch63GAZ0hYiCvirFIyUSFSkTj UDvA== MIME-Version: 1.0 X-Received: by 10.58.97.165 with SMTP id eb5mr34489285veb.40.1361483971697; Thu, 21 Feb 2013 13:59:31 -0800 (PST) In-Reply-To: References: Date: Fri, 22 Feb 2013 08:59:31 +1100 Subject: Re: Python Newbie From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 95 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361483974 news.xs4all.nl 6987 [2001:888:2000:d::a6]:33900 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:39468 On Fri, Feb 22, 2013 at 8:26 AM, Piterrr wrote= : > Hi folks. > 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. > Any comments on this before I quit my job? The first comment I would make is this: Every language you learn MUST teach you something new about programming, otherwise you haven't really learned a new language (just a new dialect of an old one). Embrace Python's differences, get to know how things work, then make your decision as to what you like and what you don't :) When there's a question of trust involving Windows Notepad, by default trust the other option. Notepad *sucks* for pretty much everything. Notepad++ is far more reliable. So is NoteTab, so is SciTE, so is pretty much anything else on the market (though the Open Watcom editor is designed exclusively for C, and may not be suitable for Python - it has a habit of converting tabs to spaces, so you may run into problems). The issue of parentheses is one of syntax. Anything that's an expression can have an extra set of parens around it; anything that's not, can't. The same will happen in most languages; I daresay C# won't let you put parentheses around the semicolon at the end of a statement, for instance. In a for loop, the 'in' keyword separates two expressions, so you can't have parens around it. I'm not sure what you mean by "indenting a full 'if' statement block". Do you mean this: code code if (some condition) { code code } code code ? Because that's a distinctly weird way to lay out code, and would be against the style guides of many organizations (definitely against any style guide that I write). Python forces you to use one of the more common styles: code code if (some condition) { code code } code code Since the braces are omitted in Python, the same Python code can equally well represent the C standards of OTBS (as shown above), Allman (with the opening brace on the next line, which is my preference when writing C)... actually, every style in http://en.wikipedia.org/wiki/Indent_style#Styles follows the pattern of having 'if' not indented and the body indented, which is what Python enforces. So this might be a change for you, but if you quit your job, chances are you'll find an identical change as you conform to some other workplace's style guide :) Of course, Python does allow and encourage the use of blank lines to help lay out your code. So if you're having trouble with the readability of statements, try judiciously adding blanks before and/or after, and see if that helps. And if all that doesn't make you happy with Python, then do look for a better job. Not every language is for everyone, and you'll produce better code as a contented C# programmer than as a miffed Python programmer :) But do consider learning multiple languages. Eric Raymond states in one of his essays [1] that you would do well to learn five basic languages: Python, C/C++, Java, Perl, and LISP. They're distinctly different from each other, and will teach different things about how to *code*, which is a skill separate from how to *code C* or how to *code Perl*. [1] http://www.catb.org/esr/faqs/hacker-howto.html ChrisA