77

I have a Python version 3.3.0 and I am not sure why it does not let me do long for b and m here... I tried to look up the answers on here and but nothing helped...thanks

im getting an error saying

NameError: global name 'long' is not defined


power = long(b) % long(m)
Jon-Eric
  • 16,977
  • 9
  • 65
  • 97
Manual
  • 1,627
  • 5
  • 17
  • 20
  • 6
    There's no more `long`. Let it go (BTW, int is the new long) – JBernardo Feb 15 '13 at 23:04
  • 1
    Why are you even trying to convert to `long` in the first place? You're only calling the function with integers, and there's no way `b % m` could be too large to fit in an `int` if `m` is an `int`. Plus, even if it _were_ too large, even in 2.x, any operation on two `int` values that's too big for an `int` returns a `long` anyway, so there's no benefit in converting in advance. – abarnert Feb 15 '13 at 23:26

1 Answers1

146

In Python 3.x, use int instead of long.

From What’s New In Python 3.0, Integers:

  • PEP 237: Essentially, long renamed to int. That is, there is only one built-in integral type, named int; but it behaves mostly like the old long type.
Jon-Eric
  • 16,977
  • 9
  • 65
  • 97