Section object created in python partially existing in hoc
Posted: Mon Feb 17, 2014 11:51 am
Dear all,
One can wrap a section object within a python class
It seems to work beautifully. For instance one could type
And have a meaningful output. Or
And see the name of the section called "something". In other it seems to work, however, when you type
or
This raise an exception. For instance the first one raise
And the second one:
This seems to indicate that the section created in python is in fact not existing in the h namespace despite its listing with h.allsec().
Is it a "bug" or a "feature"? For my usage it is a bug because I cannot create a cell model using Python and then type cellmodel.dend10.L to access the section length.
Best,
One can wrap a section object within a python class
Code: Select all
from neuron import h, nrn
class NewSection(nrn.Section):
"""
Should wrap a NEURON section
"""
def __init__(self, name="fault"):
"""Initialize the section
"""
nrn.Section.__init__(self, name=name)
Code: Select all
newSec = NewSection(name='something')
newSec.L = 123.4
h.psection(sec=newSec)
Code: Select all
for sec in h.allsec():
print sec.name()
Code: Select all
h.something
Code: Select all
h("print something.L")
Code: Select all
AttributeError: 'hoc.HocObject' object has no attribute 'something'
Code: Select all
NEURON: syntax error
near line 0
print newSec.L
^
Is it a "bug" or a "feature"? For my usage it is a bug because I cannot create a cell model using Python and then type cellmodel.dend10.L to access the section length.
Best,