Posts Tagged: Python

Javaist learning Python – Part 2 – conditions

I will write about what something I found funny – the conditions

  1. Python has a elif statement. This makes the code easier to read. Python you have a +1 from me for this
  2. Ok… now we go to the part where we find that one does not need to check for a boolean condition. Not only it does not need to check for this, it is advised NOT to check against False, True or None (a singleton that is somehow similar to the null in Java). Everything except the next statements are considered True(This reminded me of highschool and C++):
    • None
    • False
    • zero – for numeric types
    • empty dictionaries, sequences
    • 0 returned when calling __length__
    • False returned when __nonzero__ is called
  3. Now, an even stranger thing: one can have an else after a for… say whaat? yep… One can face something like
    for loop:
        if condition:
    So, what is this all about? The statement is executed when after the program finished the loop… Every time, with one exception: when a break was executed inside the loop. I still have mixed feelings about this, but probably after using more of it, it will come natural.

This was all from my Python adventure till this moment.

Javaist learning Python – Part 1

I always enjoyed stuff that had to do with programming languages and learning how to set your mind to new things/paradigms. One of my favourite courses in the University was Logic and Functional Programming – learning Prolog and LISP (Let’s Insert Some Parenthesis :D).

I played a little bit with Python for my Mater’s Thesis (Static vs Dynamic Typed Programming Languages) some years ago and I always wanted to go a little bit more in depth with it. So, now I considered it to be a great time to restart playing with Python.

The syntax I consider it to be pretty straightforward and there is quite a good documentation on the internet. But, somehow I felt I was missing the Java API docs format. For me it is more convenient to search for something and see what else I can do with that object. Also, the font size seems to be kind of unfriendly – small and a little bit cramped(I know one can resolve this with zoom on the page). I will probably get used to the documentation, but in the meantime I will crave for Java documentation.

Even though, I knew it is not a pure object oriented programming language, is it still funny to white something “outside an object”, but this did not bother me at all, on the contrary, I found it really easy to get started writing code.

Another thing I really like the command line interpretor, that can be run from the command line. Having this is really helpful for the people that have their first contacts with Python. One can actually test something before adding it to a program.

That’s all for now, but I will keep posting further impressions :).