read


read
or learn more

5 Reasons to use Python

Mar 28, 2005

1) Jython:
For those familiar with Java development, Jython is a revelation. Simply put, Jython allows you to write Python programs using the Java class libraries. This is interesting in that Python’s interactive read-eval-print loop allows interactive manipulation of Java objects. Prior to discovering Jython, my Java debug process (for certain cases) was quite arduous, but has since become quite fast. Used in conjunction with BlueJ, Jython is indispensable in my Java debugging processes. Of course, Jython’s usage should not be limited to this narrow function. In fact, it is a fully functional development framework… one that I plan to exercise to its fullest someday soon.

2) Its connection to hardware:
Projects similar to pySerial allow for excellent abstractions to computer hardware within Python. Some interesting projects use Python to connect to base hardware such as: CatFeeder and PyDmm.

3) Name-based Polymorphism:
Python uses “duck typing” for its object model. That is, a duck is not a duck because it was called a duck, but because it looks like a duck and quacks like a duck. Likewise, Python objects are defined by their capabilities, not by their inheritance structures. Therefore, if you want a class that works like a graph, then there is no need to inherit from a Graph class. Instead, you simply create a class that has the appropriate graph functions and attributes.

4) Unchecked exceptions:
Normally, this would not be an issue except that I have extensive experience with Java. That is, anyone who has written a reasonable amount of Java code knows the pain that its checked exceptions can cause. Checked exceptions refer to the nature of Java to disallow methods that do not either catch or throw exceptions. This can be quite a mess when trying to write generic middleware code and having to understand precise exception implementations. Most times the only way to deal with this case is to transform a specific exception into a more generic class. This approach however weakens the intent of the original source of the exception. Of course, there are ways around this issue (e.g. Exception Tunneling), but these methods are not widely known, understood, or adopted. In Python, exceptions can be handled or not, thus avoiding this particular limitation.

5) First-class Functions:
I love languages with first-class functions… I freaking love them. First-class functions are such that they can be used as parameters to functions, returned from functions, placed into containers, and be stored in variables.
-m

No Comments, Comment or Ping

Reply to “5 Reasons to use Python”