##// END OF EJS Templates
'interactive' kw arg added to _ip.to_user_ns
vivainio -
Show More
@@ -245,13 +245,16 b' class IPApi:'
245 245 else:
246 246 self.IP.runlines('\n'.join(lines))
247 247
248 def to_user_ns(self,vars):
248 def to_user_ns(self,vars, interactive = True):
249 249 """Inject a group of variables into the IPython user namespace.
250 250
251 251 Inputs:
252 252
253 253 - vars: string with variable names separated by whitespace
254 254
255 - interactive: if True (default), the var will be listed with
256 %whos et. al.
257
255 258 This utility routine is meant to ease interactive debugging work,
256 259 where you want to easily propagate some internal variable in your code
257 260 up to the interactive namespace for further exploration.
@@ -296,10 +299,15 b' class IPApi:'
296 299 cf = sys._getframe(1)
297 300
298 301 user_ns = self.user_ns
299
302 config_ns = self.IP.user_config_ns
300 303 for name in vars.split():
301 304 try:
302 user_ns[name] = eval(name,cf.f_globals,cf.f_locals)
305 val = eval(name,cf.f_globals,cf.f_locals)
306 user_ns[name] = val
307 if not interactive:
308 config_ns[name] = val
309 else:
310 config_ns.pop(name,None)
303 311 except:
304 312 print ('could not get var. %s from %s' %
305 313 (name,cf.f_code.co_name))
@@ -1,3 +1,9 b''
1 2007-06-13 Ville Vainio <vivainio@gmail.com>
2
3 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
4 Added kw arg 'interactive', tell whether vars should be visible
5 with %whos.
6
1 7 2007-06-11 Ville Vainio <vivainio@gmail.com>
2 8
3 9 * pspersistence.py, Magic.py, iplib.py: directory history now saved
General Comments 0
You need to be logged in to leave comments. Login now