if [conditional]:
program
else:
program_alternative
How can I redefine the symbol I use for if? What if I would like to use a unicode character -- is this allowable in python? e.g. ≸ in the place of the string "if".
Is there any way to operate on this syntax? Can I say something like type(if) or perhaps type(__if__)?
I know that python permits variables to have unicode names but what if I especially want to make my code unreadable.
Or, is this something done by the parser that cannot be influenced?
That is correct: "[if is ..] something done by the parser that cannot be influenced".
For clarification, if is a reserved keyword for a specific grammar construct, as defined by the Python language. In general, reserved words cannot be used as identifiers and have special parsing rules and behavior.
As such, type(if) is not even syntactically valid and will fail to parse: the program is invalid / illegal / made-up Python and the presented question of "does if have a type?" is not applicable.
We cannot use a keyword as variable name, function name or any other identifier. They are used to define the syntax and structure of the Python language.
There is no special "if protocol" and __if__ is an undeclared identifier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With