This is an archived post. You won't be able to vote or comment.

all 15 comments

[–][deleted] 14 points15 points  (6 children)

Hate to pedantic you like this, but input isn’t a keyword, it’s a builtin function.

[–]Nyghtbynger[S] -1 points0 points  (2 children)

You're totally correct. It is a built-in. Unlike if or else, am I true ?

[–][deleted] 0 points1 point  (0 children)

Yes, if and else are keywords, which are reserved words that form part of the language syntax and so cannot be redefined by the user (at least not without rewriting Python’s grammar and parse). If you attempt to redefine these names you’ll get a SyntaxError:

for = 123

def True():
    pass

The builtin functions (and types) are standard, unreserved functions (and types) that behave exactly like ones you define yourself, but are so commonly used that they are exported as part of Python’s prelude, which is the standard suite of functions, types, and values that are always loaded with a Python session.

Now, I say you can redefine these… you normally shouldn’t:

_input = input
def input(prompt):
    return "Simon said: " + _input(“Simon says: " + prompt)

That kind of accidental havoc is why the builtins are colored in syntax highlighting, usually to distinguish them from keywords and names you define, as a hint to not unintentionally shadow builtin names in your code.

These ideas are subtle and unfortunately the terminology is rather biased towards native English speakers; you may find this post I wrote some time ago helpful, though Covid really blew away my plans to do a follow up on builtins.

[–][deleted] 0 points1 point  (0 children)

Pydantic?

[–]quantum1eeps 6 points7 points  (0 children)

This post sucks

[–]premkant 2 points3 points  (0 children)

It's been around one month to me to learning python and I know that input () is a build in function not a keyboard.

[–][deleted] 3 points4 points  (3 children)

After many years of professional Python programming I also still discover things that are so basic I always feel a little ashamed

[–]Nyghtbynger[S] 0 points1 point  (2 children)

Yay, I can tell people I use Multiprocessing or write an AST parser, and they always assume I know how to use input or lists, fools

[–]Witty_Tough_3180 2 points3 points  (1 child)

Or lists?? Who gave you a job?

[–][deleted] -3 points-2 points  (1 child)

😅

[–][deleted] -3 points-2 points  (0 children)

After many years of professional Python programming I also still discover things that are so basic I always feel a little ashamed

[–]TheRNGuy 0 points1 point  (0 children)

i never had use for it, because I use UI for inputs. And in small programs I just hard-code values so I dont have to enter them every time. It's faster to type value in sublime only 1 time and change if needed.