Monday, May 14, 2007

First steps in Python

In my blog Python demystified I reflected on some thoughts about computer programming and the language in particular.

Ever since then I was aware and interested in this language. Remember I said:
Without any decent IDE (like Netbeans for Java) that allows for graphical programming and UI-design, I strongly doubt that Python will ever gain momentum.
Well, I found a decent IDE: ActiveState Komodo IDE.

Except for GUI it has everything, a decent IDE needs: Syntax highlighting, code completion and code folding, integration into version control (subversion), debugging and profiling.

So just as I was to change my attitude and general opinion on Python the snakes ugly head rose from the depth of my notebooks core:

(Briefly): Python allows for object oriented programming. Objects can be created and instanciated. When going out of scope they are subjected to the garbage collector for destruction. So far so good.

I tried on example program from a popular python book - it worked.

I tried to extend the program (for better understanding) - it crashed.

Well, it terminated with an exception.

Further investigation revealed:
Python stores class definition and object instances in a globally accessible list. When program flow exits the current scope, all objects within scope are subjected to garbage collection according to this global list (and in the exact order of appearance within it).

So there is the possibility that an instance "wol" may be destructed before the class definition "Person". Changing the object name to "wolf" brings it after the "Person" identifier in the globals list and thus there is an object still in memory and valid, where the class definition is destroyed. Any following destructor of the objects instance cannot be called. The code is not there any more.

Is it just me that I find these things on my first day with the language?

Other than that I am fascinated by this elegant and slim language. Worth a try.

4 comments:

Anonymous said...

hi fellas. I'm really into shoes and I was digging for that singular model. The prices as regards the velcros were about 210 dollars everwhere. But finally I base this site selling them for half price. I really love these [url=http://www.shoesempire.com]prada sneakers[/url]. I will absolutely buy these. what do you think?

Anonymous said...

Hello. And Bye.

Anonymous said...

hello everyone. I'm actually into shoes and I had been looking as far as something that particular brand. The prices as regards the velcros are all over 350 dollars everwhere. But completely I set this location selling them for the benefit of half price. I absolutely love those [url=http://www.shoesempire.com]gucci sneakers[/url]. I will probably buy those. what is your opinion?

Anonymous said...

good afternoon bros. I'm honestly into shoes and I have been digging for the sake of that singular brand. The prices seeking the velcros are around 170 dollars everwhere. But definitively I bring about this site selling them as a remedy for half price. I really like these [url=http://www.shoesempire.com]gucci sneakers[/url]. I will absolutely buy those. what can you say about it?