Python – create an EXE that runs code as written, not as it was when compiled

After some experiments I’ve found a solution. Create a separate folder source in the main folder of the application. Here will be placed source files. Also place file __init__.py to the folder. Lets name a main file like main_module.py. Add all of its contents as a data files to the py2exe configuration setup.py. Now after … Read more

Dynamic Importing of an unknown component – NextJs

I put dynamic outside of the component, and it work fine. const getDynamicComponent = (c) => dynamic(() => import(`../components/${c}`), { ssr: false, loading: () => <p>Loading…</p>, }); const Test = () => { const router = useRouter(); const { component } = router.query; const DynamicComponent = getDynamicComponent(component); return <DynamicComponent /> }

Dynamically importing Python module

It looks like this should do the trick: importing a dynamically generated module >>> import imp >>> foo = imp.new_module(“foo”) >>> foo_code = “”” … class Foo: … pass … “”” >>> exec foo_code in foo.__dict__ >>> foo.Foo.__module__ ‘foo’ >>> Also, as suggested in the ActiveState article, you might want to add your new module … Read more