[Python-ideas] Should Python have user-defined constants?
rosuav at gmail.com
Tue Nov 21 20:58:07 EST 2017
On Wed, Nov 22, 2017 at 12:51 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Wed, Nov 22, 2017 at 11:47:28AM +1100, Chris Angelico wrote:
>> On Wed, Nov 22, 2017 at 11:27 AM, Steven D'Aprano <steve at pearwood.info> wrote:
>> > Types are literally irrelevant to this, except in the sense that in many
>> > languages, including Python, the distinction between mutable and
>> > immutable is usually controlled by the type of object. But that's not
>> > fundamental to the concept: we could, if we wanted, decouple the two.
>> There's a good reason for that - the type of an object determines what
>> operations make sense (you can add two numbers together, but you can't
>> add two open sockets), and mutability impacts the validity of
>> operations. Can you give an example of where it would make sense to
>> decouple mutability from object type?
> I didn't say we should, or that I would, only that we could if we wanted
> to. But for the sake of the hypothetical argument, being able to freeze
> an object may be useful, as opposed to copying it into a new, frozen
Ah okay. Yeah, it's certainly plausible in theory, but I've never
actually wanted it.
More information about the Python-ideas