The Artima Developer Community
Sponsored Link

Python's Design Goals
A Conversation with Guido van Rossum, Part II
by Bill Venners
January 20, 2003

<<  Page 4 of 4

Advertisement

Usefulness of Privates

Bill Venners: Could you describe what the debate was about regarding the usefulness of privates in Python?

Guido van Rossum: The addition of privates was another small language change that was meant to make writing large programs easier. To me, it's mostly useful to address people's irrational fears than act as a practical tool. There are situations where privates are very useful, because you know you have your own namespace. But in many cases, I think it is overused.

People who fear that someone will call their code with the wrong arguments, and who are used to having static-typed language prevent that at the compiler level, will try to prevent that happening in their code by adding explicit assertions. People will check the types. They'll think, "Oh, this only works for strings, so now I'll assert that the input argument is a string."

That is the completely wrong approach, because someone could easily implement something that works just as well with your code and behaves sufficiently like a string. Maybe it's a proxy for a string, which behaves in almost every aspect as a string, except that its type is a proxy. That's something we use in Zope a lot. The persistency mechanism uses proxies, as does the security mechanism that executes untrusted Web- submitted code. Untrusted code is executed in a sandbox environment using proxies for objects that the code shouldn't be accessing directly. So the fact that the language doesn't enforce types at either the compiler level or the implementation level is actually helpful.

Next Week

Come back Monday, January 27 for Part III of this conversation with Python creator Guido van Rossum.

Talk Back!

What do you use Python for: scripts or apps or both? Do you agree that private members are often overused? Discuss this article in the News & Ideas Forum topic, Python's Design Goals

Resources

Python.org, the Python Language Website:
http://www.python.org/

Introductory Material on Python:
http://www.python.org/doc/Intros.html

Python Tutorial:
http://www.python.org/doc/current/tut/tut.html

Python FAQ Wizard:
http://www.python.org/cgi-bin/faqw.py

Guido van Rossum's home page:
http://www.python.org/~guido/

Other Guido van Rossum Interviews:
http://www.python.org/~guido/interviews.html

<<  Page 4 of 4


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us