Re: a couple of questions: pickling objects and strict types

Discussion in 'Python' started by Chris Angelico, Apr 6, 2013.

  1. 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
    Chris Angelico, Apr 6, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob
    Replies:
    1
    Views:
    345
    Martin v. =?iso-8859-15?q?L=F6wis?=
    Sep 11, 2003
  2. Replies:
    0
    Views:
    330
  3. Ali Syed
    Replies:
    3
    Views:
    544
    Mark McIntyre
    Oct 13, 2004
  4. Sam Kong
    Replies:
    12
    Views:
    289
    John G Harris
    Oct 17, 2006
  5. Littlefield, Tyler
    Replies:
    7
    Views:
    122
    mblume
    Apr 6, 2013
Loading...

Share This Page