Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #42869
| References | <515F1EF8.50304@tysdomain.com> |
|---|---|
| Date | 2013-04-06 11:31 +1100 |
| Subject | Re: a couple of questions: pickling objects and strict types |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.172.1365208304.3114.python-list@python.org> (permalink) |
On Sat, Apr 6, 2013 at 5:59 AM, Littlefield, Tyler <tyler@tysdomain.com> 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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: a couple of questions: pickling objects and strict types Chris Angelico <rosuav@gmail.com> - 2013-04-06 11:31 +1100
csiph-web