Compare "similar" numbers in Python
You are experiencing Python 2's integer division. When you divide two integers, Python (and many other languages) throw away the remainder. You'll want to divide by a float instead of an integer, as Dogbert indicated.
In order to sync my iPod and my local music repository, I created a unique key for each track using its metadata. The unique track consists of the track's following metadata fields:
artist, album, track number, duration. The iPod saves the track's duration in milliseconds, but my local repository saves it in seconds. For example: 437590 milliseconds on iPod is 438 seconds in my Local repository.
When I divide the ipod's track duration by 1000 I get 437. I tried using round(), but round (b.tracklen/1000) prints 437.
I can hack this by checking math.ceil(), math.floor() for the iPod duration if there is no match but it's a lousy solution.
What is the best approach to this issue?