[Tutor] python vs php5

Daniel Ehrenberg littledanehren at yahoo.com
Fri Dec 5 22:04:34 EST 2003


ali wrote:
> i've heard that php5 will include declaration of
> attributes which are 
> private,
> public and protected... aside from that interfaces
> which will be 
> implemented by
> a class can also be created...
> 
> in line with OO principles, wouldnt these features
> be good if implemented 
> in python???

In short, those principles are contrary to Python
philosophy (if you can call it that).

Most Python programmers believe that we should not
make artificial barriers between parts of a program.
Thre is no real reason to prevent programmers from
doing this type of thing; at the worst it could be
considered a small error. "We're all consenting adults
here" has been used to summarize this idea. There's
also the issue that in other languages that support
private variables and constants in order to protect
programmers, the limitations of the language often
make programmers want to bypass these limitations.

Nevertheless, it is still possible to create readonly
and private variables by defining __getattr__ and
__setattr__. There is probably some library out there
that can be used to do this more easily, but it is not
in the standard library.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/



More information about the Tutor mailing list