Skip to main content

Posts

Showing posts from December, 2015

Pythonic surprises for a Java programmer - Part 1

I had been a hard core Java programmer through out my career and had moved onto Python a while ago. The transition to python was a roller coaster ride of moments of unbridled exultation, deja vu and mirth followed by those of horror, surprise and deep disgust. Just to crib a bit, Python does not provide encapsulation...arrrghhhhh!!! and the best way to prevent people from calling an internal method seems to be to request them not to do so.
"""      This method is meant to be consumed locally.      Don't call it from outside.... please please please :( """ def _do_something_internal():     -----------------     ----------------- This blog (and a few subsequent ones, hopefully) will capture my observations on some gotchas that "pleasantly" surprise people coming from the Java domain (may be relevant to other languages as well).

Variable Scoping

Scenario 1 :
def method1():     try:           x = 10     except:            pass     print x Expec…