On 4-5-2015 17:20, Cecil Westerhof wrote:
> Potential dangerous bug introduced by programming in Python as if it
> was C/Java. :-(
> I used:
>     ++tries
> that has to be:
>     tries += 1
> 
> Are there other things I have to be careful on? That does not work as
> in C/Java, but is correct syntax.
> 

That is a broad question, but one thing that comes to mind is the current 
(python 3)
behavior of integer division. It gives the exact result and doesn't truncate to 
integers:


>>> 5/4
1.25


To be prepared for the future you should probably use python's time machine and 
enable
this behavior for 2.x as well by from __future__ import division.


Another thing is that functions are first class citizens in Python. Java will 
give a
compiler error if you forget to call them and leave out the parentheses (I 
think Java 8
allows it though). Python will accept passing them on as a function object just 
fine. If
you do this by mistake you will probably get an exception a tiny bit down the 
line, at
runtime. But it is syntactically correct so your code will compile without 
error.


-irmen

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to