39
votes

I'm new to Python. I'm writing some code in Sublime and it highlights the word 'input'

I use it as a variable name and it seems to work, so I wondered whether it may be a keyword in a newer version. (I'm currently using 2.7.5)

1
Shouldn't this get downvoted? Putting his exact question into Google comes up with the appropriate doc pages, followed by an explicit site dedicated to answering this question (reserved keywords) - TankorSmash
@TankorSmash The fact that it is a built in function doesn't really explain to a newbie like me why it would be highlighted. I come from Java where there are no built in functions. Furthermore, it's not exactly obvious to a newbie like me that sublime thinks it's a method when I give it no parameters or parentheses. - Zoltán

1 Answers

45
votes

No, input is not a keyword. Instead, it is a built-in function.

And yes, you can create a variable with the name input. But please don't. Doing so is a bad practice because it overshadows the built-in (makes it unusable in the current scope).

If you must use the name input, the convention is to place an underscore after it:

input_ = input()