[Python-ideas] Make Python code read-only

Greg Ewing greg.ewing at canterbury.ac.nz
Wed May 21 08:29:11 CEST 2014


Steven D'Aprano wrote:
> Read-only by default would play havok with such simple idioms as global 
> variables.

I don't see why there couldn't be a way to exempt selected
names in a module from read-only status.

An exemption could be inferred whenever a name is
referenced by a 'global' statement. There should also be
a way to explicitly mark a name as exempt, to take care
of sys.stdout etc., and cases where the only mutations are
done from a different module, so there is no global
statement.

For modules implemented in Python, the explicit marker
could consist of a global statement at the top level,
which is currently allowed but redundant.

-- 
Greg


More information about the Python-ideas mailing list