Fix Python – Why does integer division yield a float instead of another integer?

Consider this division in Python:
Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> 2/2

Is this intended? I strongly remember earlier versions returning int/int = int. What should I do? Is there a new division operator or must I always ….

Fix Python – Safest way to convert float to integer in python?

Python’s math module contain handy functions like floor & ceil. These functions take a floating point number and return the nearest integer below or above it. However these functions return the answer as a floating point number. For example:
import math

Now f returns:

What is the safest way to get an integer out of this flo….

Fix Python – How do you express binary literals in Python?

How do you express an integer as a binary number with Python literals?
I was easily able to find the answer for hex:
>>> 0x12AF
>>> 0x100

and octal:
>>> 01267
>>> 0100

How do you use literals to express binary in Python?

Summary of Answers

Python 2.5 and earlier: can express binary using int(‘01010101111’,2) but not with a lite….