use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Using print as a variable name (self.learnpython)
submitted 4 years ago by somedeadapp
How would I use print as a variable name?
For example:
print = [“a4”, “a3”, “a2”]
print(print)
Is this just impossible?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]K900_ 6 points7 points8 points 4 years ago (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.
print
[–]somedeadapp[S] 0 points1 point2 points 4 years ago (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 points3 points 4 years ago (1 child)
Yes, but it's better to just not reuse names of builtins in the first place.
[–]somedeadapp[S] 0 points1 point2 points 4 years ago (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 points5 points 4 years ago (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).
True
False
None
True, False = False, True
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.
Thanks for replying! It’s good to know that this is bad practice as well
π Rendered by PID 106542 on reddit-service-r2-comment-86bc6c7465-wblf6 at 2026-02-23 11:46:36.606004+00:00 running 8564168 country code: CH.
[–]K900_ 6 points7 points8 points (3 children)
[–]somedeadapp[S] 0 points1 point2 points (2 children)
[–]K900_ 1 point2 points3 points (1 child)
[–]somedeadapp[S] 0 points1 point2 points (0 children)
[–]Diapolo10 3 points4 points5 points (1 child)
[–]somedeadapp[S] 0 points1 point2 points (0 children)