python restructure