Not possible to hide local variables

Marko Rauhamaa marko at pacujo.net
Thu Apr 30 01:10:34 EDT 2015


Steven D'Aprano <steve+comp.lang.python at pearwood.info>:

> If you have a Java background, you might find this useful:
>
> http://dirtsimple.org/2004/12/python-is-not-java.html
>
> http://dirtsimple.org/2004/12/java-is-not-python-either.html

Unfortunately, I didn't find those articles all that insightful.

The one big difference between Java and Python is interfaces vs
ducktyping. In Java, you do everything through formal interfaces. In
Python, you do nothing through formal interfaces.

I occasionally see a Java class that doesn't implement an interface, and
there are abstract Python base classes that emulate interfaces. However,
I think both practices are nonidiomatic and should be avoided in their
respective domains.

Anonymous nested inner classes are syntactically cumbersome. However,
conceptually they are a fabulous device. They were popularized in Java
and I use them quite frequently in Python.


Marko



More information about the Python-list mailing list