create the list of paths from which filename module was included for every filename in new_modules, only is filename has '__file__' attribute, substitute the resulting list for new_filenames.
new_filenames = [ filename . __file__ for filename in new_modules if hasattr ( filename , '__file__' ) ]