for name in registryprint(name'=>'registry[name]type(registry[name])print('\nmanual calls:'print(spam( )print(ham( ) eggs( print(xinvoke objects manually later calls not intercepted print('\nregistry calls:'for name in registryprint(name'=>'registry[name]( )invoke from registry when this code is run the decorated objects are added to the registry by namebut they still work as originally coded when they're called laterwithout being routed through wrapper layer in factour objects can be run both manually and from inside the registry tablec:\codepy - registry-deco py registryspam =ham =eggs =manual calls registry callsspam = ham = eggs = user interface might use this techniquefor exampleto register callback handlers for user actions handlers might be registered by function or class nameas done hereor decorator arguments could be used to specify the subject eventan extra def statement enclosing our decorator could be used to retain such arguments for use on decoration this example is artificialbut its technique is very general for examplefunction decorators might also be used to process function attributesand class decorators might insert new class attributesor even new methodsdynamically consider the following function decorators--they assign function attributes to record information for later use by an apibut they do not insert wrapper layer to intercept later callsaugmenting decorated objects directly def decorate(func)func marked true return func assign function attribute for later use @decorate def spam(ab)managing functions and classes directly