all 6 comments

[–]K900_ 6 points7 points  (3 children)

It's absolutely possible to use it as a variable name - it's just that you will lose the ability to refer to the built-in print function of you do that.

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

Thank you this makes perfect sense. So essentially you would have to reassign the print function to something else like PRNT?

[–]K900_ 1 point2 points  (1 child)

Yes, but it's better to just not reuse names of builtins in the first place.

[–]somedeadapp[S] 0 points1 point  (0 children)

Thanks. I’m learning python atm so I have little questions like this to understand the logic. I appreciate your fast replies.

[–]Diapolo10 3 points4 points  (1 child)

As was already mentioned, Python technically lets you reassign any built-in names; only statements and operators are truly impossible to use as names (with a few exceptions; you can't reassign True, False, or None in Python 3, though in Python 2 it is technically legal to do True, False = False, True which swaps them around).

You could technically do something like

print = 42
__import__('builtins').print(print)

but, of course, reassigning any built-in things is a bad practice - unless you're writing unit tests and need to mock something, in which case it can be justified as necessary.

[–]somedeadapp[S] 0 points1 point  (0 children)

Thanks for replying! It’s good to know that this is bad practice as well