generate dictionary of hoc (h.) things
Posted: Fri Nov 21, 2014 5:00 pm
I wanted a dictionary of hoc stuff for reasons that in retrospect was unnecessary, but having done this I thought I would share it
hdict = dict([(name,h.__getattribute__(name)) for name in dir(h) if hasattr(h,name)])
the hasattr() turned out to be the trick since for reasons obscure some things turn up in the dir() that are not accessible -- thanks to robert mcdougal for showing me that
note that this is not a dynamic dict so has to be regenerated after loading something
hdict['tstop'] # not found
h.load_file("stdrun.hoc")
hdict = dict([(name,h.__getattribute__(name)) for name in dir(h) if hasattr(h,name)])
hdict['tstop'] # 5.0
hdict = dict([(name,h.__getattribute__(name)) for name in dir(h) if hasattr(h,name)])
the hasattr() turned out to be the trick since for reasons obscure some things turn up in the dir() that are not accessible -- thanks to robert mcdougal for showing me that
note that this is not a dynamic dict so has to be regenerated after loading something
hdict['tstop'] # not found
h.load_file("stdrun.hoc")
hdict = dict([(name,h.__getattribute__(name)) for name in dir(h) if hasattr(h,name)])
hdict['tstop'] # 5.0