Dmandel wrote:IPulse1 does not seem to be an instance of the soma section...
True, but completely unrelated to the reason why this statement
stim = h.IPulse1(h.soma(0.5))
failed, and also completely unrelated to the error message
AttributeError: 'hoc.HocObject' object has no attribute 'IPulse1'
The statement
soma = h.Section()
creates a section that is known to Python as soma. Because of these facts (a section exists, and its Python name is soma), it is only necessary to do
stim = h.IPulse1(soma(0.5))
So to review, this would succeed:
soma = h.Section()
stim = h.IPulse1(soma(0.5))
Don't try to get too fancy with the "name" argument to h.Section().
soma = h.Section(name = 'soma')
doesn't mean that hoc now has a token called 'soma' that is synonymous with the Python token 'soma'. To quote a recent discussion with Michael Hines,
The 'name' arg for the section constructor is embarassingly misleading. It only refers to the label printed by GUI tools and topology and psection. That label cannot be used by the hoc interpreter as it is not added to the hoc symbol table.
"Whazzat?"
In the context of the discussion you and I are having, it's why the statement
stim = h.IPulse1(h.soma(0.5))
failed, and produced this error message
AttributeError: 'hoc.HocObject' object has no attribute 'IPulse1'
If hoc recognized the token 'soma' as the name of a section,
stim = h.IPulse1(h.soma(0.5))
would have succeeded. But the statement
soma = h.Section(name = 'soma')
doesn't make hoc add 'soma' to its symbol table, so as far as hoc is concerned there isn't anything (let alone a section) called soma, and that's why
stim = h.IPulse1(h.soma(0.5))
fails. h.IPulse1() expects its argument to refer to a nrn.Segment object (because a point process must be associated with a segment), but h.soma(0.5) doesn't return a useful result. If you execute
soma(0.5)
you'll get a result something like
<nrn.Segment object at 0xb73c9fc8>
but if you execute
h.soma(0.5)
you'll get this error message
AttributeError: 'hoc.HocObject' object has no attribute 'soma'
I'm sure there's a reason why
stim = h.IPulse1(h.soma(0.5))
generates the rather uninformative error message
AttributeError: 'hoc.HocObject' object has no attribute 'IPulse1'
but for the moment I think I need to be excused from class for a while because my brain is full.