sloria/konch

Pick up everything imported using "from X import *" for the context

robintw opened this issue · 2 comments

Is there any way that Konch can pick up everything that is brought into the namespace from a from module import * import command and put it in the context?

A number of tools I use have a way of importing like that to provide a number of handy things in the namespace, and it'd be great if Konch could pick them all up.

In your .konchrc, you could do:

import os
import konch
context = {
    'os': os
}
from module import *
context.update(locals())

konch.config({
    'context': context,
})

EDIT: Or even just:

import konch

from module import *
from anothermodule import *

konch.config({
    'context': locals(),
})

Thanks - that all works well.