chprice / Python-Chat-Program

A P2P chat program designed to work on LANs or across the internet for chatting.
57 stars 44 forks source link

Replace power() with built-in pow() #4

Closed jayelm closed 10 years ago

jayelm commented 10 years ago

The power function declaration is superfluous. Python's built in pow() takes care of powers, and is functionally equivalent to power(). They both return integers when integers are provided as well.

After declaring power(), this code can guarantee the functions are similar (at least with ints. With some floats, power() will throw an exception):

>>> for x in range(0, 20):
...     for y in range(0, 20):
...         assert power(x, y) == pow(x, y)
chprice commented 10 years ago

Good call, thanks for replacing that.