Skip to content

Python reloading in repl #44

Description

@guibou

If you load some modules with pymain, such as:

          [pymain|
            import json
            import importlib
            
            import my_business_module

Unfortunately, even after a ghci reload (e.g. :reload), the python context stays initialised and hence the import are NOT reloaded. This can be confusing (I spent a bit of time tuning my haskell code and reloading without sucess and even with confusing errors before realizing that I needed to reload the repl).

A workaround is to use importlib to reload the modules:

          [pymain|
            import json
            import importlib
            
            import my_business_module
            importlib.reload(my_business_module)

That's a bit slower and comes with few gurantee (the reload model of python is not perfect), but it saves a full ghci reload in many context.

If you agree, I'll add a line in haddock in the section Troubleshooting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions