+ 3
How to make variables with name of functions in python
Recently I was working on a code myself where i needed to make a variable called class but i couldn't do it because it was throwing an error Can anyone tell me if it's possible to make variables such as print, if etc...
6 odpowiedzi
+ 3
sure you can you can make it with underscore but putting undeescore before variable name can mean a private variable etc..but why would you want a variable called class
+ 2
It is not a good thing if you overwrite the built-in keywords. How would you access them if you need to use them in their original purpose later? It is a necessary restriction.
+ 1
class is a reserved identifier which is used to make class so you cannot use it as a variable
+ 1
Bob_Li thanks
I understood
0
A͢J isn't there any way to use other things like functions as variable names?
0
Ion Kare thanks for help
I was just trying to code some random things and then tried to use class as variable but it didn't work so i just used cls insted