[Tutor] creating read only attributes

Thomi Richards thomi at imail.net.nz
Fri Nov 21 23:19:10 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
>
> However, I
> don't see why you really need to do this. It is a
> convention to not change things that are in allcaps,
> so if someone wants to write a working application,
> they probably won't do that. In general, creating
> private variables is considered unpythonic, so it is
> probably the same for these immutable variables.
>

Isn't one of the basic tenants of OO that objects should be like "magic black 
boxes", and their inner workng should be invisable to outside observers? It 
seems to me that private variables are very important for this reason...

The same goes for read-only attributes..... OK, so we could all use lots of 
methods, but if you ask me, a whole heap od methods called "set_a", "set_b", 
"set_c" etc. etc. is ugly... (the pyGTK classes come to mind). Wouldn't it be 
nice to be able to treat these attributes as read-only (or write-only), and 
have them behave as normal variables, rather than having to wrap functions 
around them?


Thanks,
- -- 
Thomi Richards,
http://once.sourceforge.net/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/vuO+2tSuYV7JfuERAnl2AJoDjE8lrqB/0Jj3Y0pJzI0fi/LmewCfbHf6
4xLupw8zuji7L1qms6X5COo=
=bBVP
-----END PGP SIGNATURE-----




More information about the Tutor mailing list