<br><br><div class="gmail_quote">On Fri, Jan 18, 2013 at 10:08 AM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On Fri, Jan 18, 2013 at 5:22 PM, David Townshend <<a href="mailto:aquavitae69@gmail.com">aquavitae69@gmail.com</a>> wrote:<br>
> As has already been pointed out, syntax to allow compile-time optimisations<br>
> doesn't really make much sense in python, especially considering the<br>
> optimisations Pypy already carries out.  Some sort of "finalise" option may<br>
> be somewhat useful (although I can't say I've ever needed it).  To avoid<br>
> adding a new keyword it could be implementer as a function, e.g.<br>
> finalise("varname") or finalise(varname="value").  In a class, this would<br>
> actually be quite easy to implement by simply replacing the class dict with<br>
> a custom dict designed to restrict writing to finalised names.  I haven't<br>
> ever tried changing the globals dict type, but I imagine it would be<br>
> possible, or at least possible to to provide a method to change it.  I<br>
> haven't thought through all the implications of doing it this way, but I'd<br>
> rather see something like this than a new "const" keyword.<br>
<br>
</div>While you won't see module level support (beyond the ability to place<br>
arbitrary classes in sys.modules), this is already completely possible<br>
through the descriptor protocol (e.g. by creating read-only<br>
properties).<br>
<br>
Cheers,<br>
Nick.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>   |   Brisbane, Australia<br>
</div></div></blockquote><div><br>True.  I was going for something which might work in modules too, but module-level descriptors would probably be a more consistent approach anyway.  This is actually something I have needed in the past, and got around it by putting a class in sys.modules.  Maybe finding a neat way to write module-level descriptors would be more useful, and cover the same use case as consts?<br>

<br>David<br></div></div>