Hacker News new | ask | show | jobs
by pmiller2 5049 days ago
Abstract base classes. See http://www.doughellmann.com/PyMOTW/abc/
1 comments

Absent static type checking and manifest typing, abstract base classes do much less than Java interfaces.
Ah yes, the age-old static typing vs duck typing argument.

Sure, in theory static typing can catch bugs. But doing it like Java does it is a lot of work per real bug actually caught.

Whether or not that's true, it is a concrete difference between Python and Java. Python is not a superset of Java.
I never claimed that the two were the same language. My claim was that you can take anything written in Java and pretty much directly translate it to Python.

The fact that there are things Java will flag as errors that a Python translation does not, does not change this fact.

As I said, you seem to be claiming that Python is a superset of Java, not equivalent to it, and that claim is manifestly false. Errors that are detected in one place and not in another are a manifest difference.

Also, Java threads and anonymous classes do not translate directly to Python.

Python has threads.

In Python classes are first class objects, and you can easily do anything you could do with Java anonymous classes on the fly. Furthermore Java anonymous classes are usually used as a verbose replacement for a lack of closures. But in Python you can create closures and pass them around. (You do have to do some juggling to mutate variables, but 1 element arrays are only a slight pain to work with.)