+ 15
print can be a name of a variable?
python question
26 Antworten
+ 9
You could have tried doing it in code playground.
+ 8
Ben Allen (Njinx) check this out
https://code.sololearn.com/c561KbRLt2f4/?ref=app
+ 7
i ask for print only ?
+ 7
we can name a variable print, but we canot after use print to appear some thinks, solution is to use del print , and if you try more to zrite del print , pytjon send to you print is note defined, the standar print is a callable object , you can make sure by callable(print) and you reciev True , if you name some think not callable print , now the callable (print) appe ae False , finally , print ,input,bool,chr,ord ,eval, callable, isinstance ,all functions and class ,we can use they name as a name of our variable, but we lose the function or class that we take her name.
+ 3
yes, but you won't be able to use print to output something.
+ 3
4G3N7 No. print is a reserved keyword, it won't work as a variable name.
+ 3
def print(*args, **kwargs): pass
print('hello world')
+ 3
4G3N7 Huh, I stand corrected. I still wouldn't recommend actually doing this.
+ 3
print is only a reserved word in Python 2, Python 3 changed it to a function, which is essentially a variable you can call.
So yes, you can create a variable called print and even replace the default function in Python 3.
+ 1
yes you can do.this code will help you.
# to print all the local variables
for i in locals().keys():
print(i)
# to print all the global variables
for i in globals().keys():
print(i)
+ 1
reserved words can not be used cuz it's compiler's.
you can add a number or _ at the last of it.
examples: print5, print_, print____
+ 1
no
+ 1
the print method is a reserved word.
Unless you modify print as print_,or print1 or another variable name #print2 it will create its own object, but print cannot be an Object variable itself.
0
no,as it is a reserved keyword of python script
0
yes it can be a variable name but you need to change some of it's letters like :
Print = 0
print_ = 0
PRINT = 0
and so on !
0
print is a function is a reserved word will always this name print becouse its define in python api now variable can be the name you like following the names rules
0
No. Print is a reserved word
0
No
0
No you can't use Print
0
no