Rationale for read-only property of co_code
John Nagle
nagle at animats.com
Thu Apr 3 01:27:00 EDT 2008
Dan Upton wrote:
>> The thing I've been wondering is why _is_ it read-only? In what
>> circumstances having write access to co_code would break the language
>> or do some other nasty stuff?
>>
>> João Neves
>
> I can't speak to Python's implementation in particular, but
> self-modifying code in general is unpleasant.
Yes. Self-modifying code has a long and painful history.
It's sometimes useful to generate and execute code
dynamically, but that's different than modifying running code.
Python already has "eval", plus the ability to compile and include
new code at run time, so the useful facilities are already working.
John Nagle
More information about the Python-list
mailing list