Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NameError: global name 'long' is not defined

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) 
like image 975
Manual Avatar asked Feb 15 '13 23:02

Manual


People also ask

How do I fix the NameError in Python?

The Python "NameError: name is not defined" occurs when we try to access a variable or function that is not defined or before it is defined. To solve the error, make sure you haven't misspelled the variable's name and access it after it has been declared.

What causes NameError in Python?

NameError is raised when the identifier being accessed is not defined in the local or global scope.

What is a NameError?

NameError is a kind of error in python that occurs when executing a function, variable, library or string without quotes that have been typed in the code without any previous Declaration. When the interpreter, upon execution, cannot identify the global or a local name, it throws a NameError.


1 Answers

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.
like image 60
Jon-Eric Avatar answered Oct 04 '22 05:10

Jon-Eric