
Mark Hammond wrote:
MAL writes:
- How to spell it? x.freeze()? x.readonly()?
How about .lock() and .unlock() ?
I'm with Greg here - lock() and unlock() imply an operation similar to threading.Lock() - ie, exclusivity rather than immutability.
I don't have a strong opinion on the other names, but definately prefer any of the others over lock() for this operation.
Funny, I though that .lock() and .unlock() could be used to implement exactly what threading.Lock() does... Anyway, names really don't matter much, so how about: .mutable([flag]) -> integer If called without argument, returns 1/0 depending on whether the object is mutable or not. When called with a flag argument, sets the mutable state of the object to the value indicated by flag and returns the previous flag state. The semantics of this interface would be in sync with many other state APIs in Python and C (e.g. setlocale()). The advantage of making this a method should be clear: it allows writing polymorphic code. -- Marc-Andre Lemburg ______________________________________________________________________ Company: http://www.egenix.com/ Consulting: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/