Take the 2-minute tour ×

Why is python telling me "TypeError: pow expected 2 arguments, got 3" despite it working in IDLE (sometimes it tells me that in IDLE as well)? im simply doing pow(a,b,c). my program is very short and i do not change the definition of pow at any time since i need to use it for some exponentiation.

NOTE: This is the pow from __builtin__, not Math

share|improve this question

3 Answers 3

up vote 9 down vote accepted

Built-in pow takes two or three arguments. If you do from math import * then it is replaced by math's pow, which takes only two arguments. My recommendation is to do import math, or explicitly list functions you use in import list. Similar issue happens with open vs. os.open.

share|improve this answer
ah... maybe that's why. thanks!!!!! err... would an import from another file affect it? im importing another program i wrote which also has from math import * –  calccrypto Jul 23 '10 at 21:03
@calccrypto: If you're importing the another program with from p import * then yes. Use import p or list explicitly from p import [...]. –  sdcvvc Jul 23 '10 at 21:09


pow(x, y[, z]) Return x to the power y; if z is present, return x to the power y, modulo z (computed more efficiently than pow(x, y) % z). The two-argument form pow(x, y) is equivalent to using the power operator: x**y.

The arguments must have numeric types. With mixed operand types, the coercion rules for binary arithmetic operators apply. For int and long int operands, the result has the same type as the operands (after coercion) unless the second argument is negative; in that case, all arguments are converted to float and a float result is delivered. For example, 10*2 returns 100, but 10*-2 returns 0.01. (This last feature was added in Python 2.2. In Python 2.1 and before, if both arguments were of integer types and the second argument was negative, an exception was raised.) If the second argument is negative, the third argument must be omitted. If z is present, x and y must be of integer types, and y must be non-negative. (This restriction was added in Python 2.2. In Python 2.1 and before, floating 3-argument pow() returned platform-dependent results depending on floating-point rounding accidents.)

Perhaps you're violating the bold portion?

share|improve this answer
no. im sure that all the values are positive integers edit: yep. a,b,c = 9, 4, 225 –  calccrypto Jul 23 '10 at 21:02

If you are using math functions a lot and the three parameter version of pow infrequently a way around this in python 2.7 is to import __builtin__ and call __builtin__.pow for the 3 paramete

share|improve this answer
There should be two underscore characters either side of 'builitin' in both cases but the formatting interpreted that as bold font - not sure what to do about thaat. –  Paula Thomas Feb 13 '13 at 12:14

Your Answer


