advanced programming techniques class orddef __getattr__(selfchar)return ord(charwith the ord class availablewe can create an instanceord ord()and then have an alternative to the built-in ord(function that works for any character that is valid identifier for exampleord returns ord returns and ord returns (but ord and similar are syntax errors note that if we typed the ord class into idle it would not work if we then typed ord ord(this is because the instance has the same name as the built-in ord(function that the ord class usesso the ord(call would actually become call to the ord instance and result in typeerror exception the problem would not arise if we imported module containing the ord class because the interactively created ord object and the built-in ord(function used by the ord class would be in two separate modulesso one would not displace the other if we really need to create class interactively and to reuse the name of built-in we can do so by ensuring that the class calls the built-in--in this case by importing the builtins module which provides unambiguous access to all the built-in functionsand calling builtins ord(rather than plain ord(here' another tiny yet complete class this one allows us to create "constantsit isn' difficult to change the values behind the class' backbut it can at least prevent simple mistakes class constdef __setattr__(selfnamevalue)if name in self __dict__raise valueerror("cannot change const attribute"self __dict__[namevalue def __delattr__(selfname)if name in self __dict__raise valueerror("cannot delete const attribute"raise attributeerror("'{ }object has no attribute '{ }'format(self __class__ __name__name)with this class we can create constant objectsayconst const()and set any attributes we like on itfor exampleconst limit but once an attribute' value has been setalthough it can be read as often as we likeany attempt to change or delete it will result in valueerror exception being raised we have not reimplemented __getattr__(because the base class object __getattr__(method does what we want--returns the given attribute' value or raises an attributeerror exception if there is no such attribute in the __delattr__(method we mimic the __getattr__(method' error message for nonexistent attributesand to do this we must get the name of the class we are in as well as