To learn more about deprecated keywords, you can check out What’s New In Python 3.0.
Dealing With Deprecated Keywords
There are two keywords that were deprecated in Python 3.0,
exec. In the release notes of Python 3.0, you got the reasoning for it: “The print statement has been replaced with a
print() function, with keyword arguments to replace most of the special syntax of the old
exec() is no longer a keyword; it remains as a function.”
So both former keywords have been basically replaced by a function with the same name. Does that mean that you are free to use them now? Well, let me show you why you still shouldn’t use them as a variable name in your code. So when you just type
And that means you can actually say, my variable name is
"CMYK". And if I call it, then
CMYK is returned. However, if you want to use the
print() function at any point later in your code, then you will get a
TypeError, and this can really mess up your code. So don’t use
exec as variable names.
It’s important to note that this word of caution isn’t just for the former
Become a Member to join the conversation.