[Tutor] What is "pythonic"?

Karl Fast karl.fast at pobox.com
Fri Oct 24 15:32:17 EDT 2003

> I came across a quote "we are all consenting adults here" I think in
> explaining why it is not necessary to have type declaration
> statements in Python, in contrast to other strongly-typed languages.

This expression is also used in the object-oriented python
literature to explain python's attitudes about private class
members, which python doesn't have. 

When you create an instance of some class there is nothing to
prevent you from poking around inside and using various internal,
private methods that are (a) necessary for the class to function,
BUT (b) not intended for direct use/access.

Nothing is really private in python. No class or class instance can
keep you away from all what's inside (this makes introspection
possible and powerful). Python trusts you. It says "hey, if you want
to go poking around in dark places, I'm gonna trust that you've got
a good reason and you're not making trouble."

After all, we're all consenting adults here.

C++ and Java don't have this philosophy (not to the same extent).
They allow you create private methods and static members. 

Perl culture is like python in this respect, but Perl expresses the
sentiment a bit differently. As the Camel book puts it,

  "a Perl module would prefer that you stayed out of its living room
  because you weren't invited, not because it has a shotgun."

But the sentiment is identical.

More information about the Tutor mailing list