how to write-protect names

Gregor Lingl glingl at aon.at
Wed Sep 17 23:13:45 CEST 2003


Peter Hansen schrieb:

> What exactly do you need this for?  If you describe the purpose
> you have in mind for it we can provide the best approach, or 
> tell you that we don't think you should bother. ;-)
> 
> -Peter

I'm writing a module for teaching young students. It contains
e. g. a function width, which assigns a value to some (hidden)
variable:

 >>> width(5)

Now my experience is, that from time to time some of my
students write (erroneously)

 >>> width = 5

which renders the function width unaccessible for future
use. (Moreover the next

 >>> width(10)

will result in a rather strange error-message, like
int-object is not callable ... (my students won't
underswtand it).

Wouldn't it be useful if the name width were write-protected

Regards,
Gregor





More information about the Python-list mailing list