/ module definition */*************************static struct pymoduledef cenvironmodule pymoduledef_head_init"cenviron"/name of module *"cenviron doc"/module documentationmay be null *- /size of per-interpreter module state- =in global vars *cenviron_methods /link to methods table *}/*************************/ module initializer */*************************pymodinit_func pyinit_cenviron(/called on first import */name matters if loaded dynamically *return pymodule_create(&cenvironmodule)though demonstrativethis example is arguably less useful now than it was in the first edition of this book--as we learned in part iinot only can you fetch shell environment variables by indexing the os environ tablebut assigning to key in this table automatically calls ' putenv to export the new setting to the code layer in the process that isos environ['key'fetches the value of the shell variable 'key'and os environ['key']=value assigns variable both in python and in the second action--pushing assignments out to --was added to python releases after the first edition of this book was published besides illustrating additional extension coding techniquesthoughthis example still serves practical purposeeven todaychanges made to shell variables by the code linked into python process are not picked up when you index os environ in python code that isonce your program startsos environ reflects only subsequent changes made by python code in the process moreoveralthough python now has both putenv and getenv call in its os moduletheir integration seems incomplete changes to os environ call os putenvbut direct calls to os putenv do not update os environso the two can become out of sync and os getenv today simply translates to an os environ fetchand hence will not pick up environment changes made in the process outside of python code after startup time this may rarelyif everbe an issue for youbut this extension module is not completely without purposeto truly interface environment variables with linked-in codewe need to call the library routines directly (at least until python changes this model again!the cenviron file in example - creates python module called cenviron that does bit more than the prior examples--it exports two functionssets some exception descriptions explicitlyand makes reference count call for the python none object (it' not created anewso we need to add reference before passing it to pythonas beforewrapping environment calls