Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'syntax': 0.04; 'model,': 0.05; 'compiler': 0.07; 'variables': 0.07; 'runtime': 0.09; 'way:': 0.09; 'python': 0.11; 'def': 0.12; 'c/c++': 0.16; 'caveat': 0.16; 'cleaner': 0.16; 'declaration': 0.16; 'declarations': 0.16; 'declared': 0.16; 'etc...': 0.16; 'foo"': 0.16; 'foo():': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'give.': 0.16; 'globals': 0.16; 'nesting': 0.16; 'scopes': 0.16; 'subject:questions': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'module': 0.19; "python's": 0.19; 'written,': 0.19; '(the': 0.22; 'load': 0.23; 'errors.': 0.24; 'pass': 0.26; 'read,': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'words': 0.29; "doesn't": 0.30; 'errors': 0.30; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'code': 0.31; 'catching': 0.31; 'names.': 0.31; 'quite': 0.32; 'sense': 0.34; "i'd": 0.34; 'received:209.85': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'c++': 0.36; 'useful': 0.36; 'error.': 0.37; 'level': 0.37; 'received:209': 0.37; 'area': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'though,': 0.39; 'to:addr:python.org': 0.39; 'catch': 0.60; 'helps': 0.61; 'simple': 0.61; "you'll": 0.62; 'name': 0.63; 'high': 0.63; 'such': 0.63; 'fact,': 0.69; 'legal': 0.71; 'clearer': 0.84; 'effectively,': 0.84; 'etc,': 0.84; 'notion': 0.91; '2013': 0.98 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; bh=qtX0GWtfdHgH9Zzak3GvrUEoOMksmAj65V8SVIaf3Fw=; b=W3BSJx5Bu6b9oAVLb2QpfHQMQwv8Yl2C7taQ2Kg2uPpGmW1aNk8uxfBUTDPpQOBumi cKGUyd5VVHnSpkHSGv9zNRYc2LpVJciFbgDG1HXJWIGtk6jof0wHq+mr/8ucuTq+DOVN wUWlhX+T8zjmu4W1A86XKsrlfMuqnqAtzGIFVODFboVc524y89rO+U2ZF9DSZKJ2tcbJ 3e5iQyB7ythjZ4jjijS6SuMpEEBZVOXS8MXqEZsjqv8Ny6CFrouNkUR4tda9By+2oZLO /OpHJgXLOuwInVQxKgpN9DE6SxMCPPbEkIuLueXptXVnGmXERkqg2X1AZJBEm5XKnlK7 KLcQ== MIME-Version: 1.0 X-Received: by 10.58.75.46 with SMTP id z14mr9756930vev.52.1365208295895; Fri, 05 Apr 2013 17:31:35 -0700 (PDT) In-Reply-To: <515F1EF8.50304@tysdomain.com> References: <515F1EF8.50304@tysdomain.com> Date: Sat, 6 Apr 2013 11:31:35 +1100 Subject: Re: a couple of questions: pickling objects and strict types From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365208304 news.xs4all.nl 6888 [2001:888:2000:d::a6]:51167 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42869 On Sat, Apr 6, 2013 at 5:59 AM, Littlefield, Tyler wrote: > I come from a c++ background; though it doesn't help in catching runtime > errors, being able to compile a program helps catch a lot of syntax errors. Syntax errors you'll still catch just by attempting to load up the module in any way: def foo(): if True # oops, no colon pass You don't need to execute that particular line of code to get the error. But there are a whole lot of errors that a C++ compiler would catch that Python leaves until run-time, such as variable name misspellings, data type mismatches, etc, etc... however, this is part of what gives Python its flexibility. In fact, a lot of things that would be errors in C/C++ are actually quite legal and useful in Python. The one area that I would prefer the C model, though, is declared variables vs freely-usable names. I prefer the Python notion of "names" rather than "variables" (the difference takes a lot of words to explain, but it makes VERY good sense - in a high level language), but I do like the infinite nesting of scopes and simple catching of misspellings that the declarations give. Effectively, what I'd like to see is a declaration "local foo" instead of Python's choice of "global foo" - with the caveat that globals can be read, but not written, without that declaration. I think it's clearer and cleaner to declare all locals. But that's a small matter. ChrisA