Two forward slashes in Python
Question: I came across this sample of code from a [radix
sort](http://en.wikipedia.org/wiki/Radix_sort#Example_in_Python):

    
    
    def getDigit(num, base, digit_num):
        # pulls the selected digit
        return (num // base ** digit_num) % base
    

What does the '`//`' do in Python?


Answer: `//` is the integer division operator.

In Python 3 the ordinary `/` division operator returns floating point values
even if both operands are integers, so a different operator is needed for
integer division. This is different from Python 2 where `/` performed integer
division if both operands where integers and floating point division if at
least one of the operands was a floating point value.

The `//` operator was first introduced for forward-compatibility in Python 2.2
when it was decided that Python 3 should have this new ability. Together with
the ability to enable the Python 3 behaviour via `from __future__ import
division` (also introduced in Python 2.2), this enables you to write Python
3-compatible code in Python 2.

