Paul Moore <p.f.mo...@gmail.com>:

> To put it another way, in C const is a property of the variable being
> declared, not the value assigned to it. In Python, variables aren't
> declared, and constness is an inherent property of the value (or its
> type). One interesting question which this does raise is whether
> there's a place for "const" in type annotations - I suspect not,
> because it's either trivial (the type is immutable) or too hard to
> define (you'd need to recursively know for all methods whether they
> mutate the value).

I don't think that's the core issue.

User-defined classes (or, rather, objects) are often mutable. The
question is who gets to modify them and what modifieds them (methods can
have surprising side effects).

"Const" would convey some of that information. However, why "const" out
of the myriads of restrictions?

The nice thing about Python is that I don't get to formally declare
those things, and that makes my life easier. I don't have to worry about
finding the right combination of these formal comments -- because I
can't!


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to