Re: 2.7 source import in python 3.x

2016-04-04 Thread Robin Becker
On 04/04/2016 12:15, Peter Otten wrote: .. In the example section they have (for 3.4 and above) spec = importlib.util.spec_from_file_location(module_name, file_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) The importlib with all its factories is a

Re: 2.7 source import in python 3.x

2016-04-04 Thread Peter Otten
Robin Becker wrote: > A user points out that this code in reportlab uses the now deprecated imp > module > > def _fake_import(fn,name): > if os.path.isfile(fn): > import imp > with open(fn,'rb') as f: > imp.load_source(name,fn,f) > > and suggests I use importl

2.7 source import in python 3.x

2016-04-04 Thread Robin Becker
A user points out that this code in reportlab uses the now deprecated imp module def _fake_import(fn,name): if os.path.isfile(fn): import imp with open(fn,'rb') as f: imp.load_source(name,fn,f) and suggests I use importlib SourceFileLoader. Is there anything wrong