pointprocess does not know its own type/name

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
eacheon
Posts: 97
Joined: Wed Jan 18, 2006 2:20 pm

pointprocess does not know its own type/name

Post by eacheon » Tue Aug 25, 2009 2:16 pm

Using

Code: Select all

 p = neuron.new_point_process('ExpSyn') 
I can get the name of p by access name attribute. But since neuron.new_point_process is becoming obsolete, from the correspondent usage

Code: Select all

a = h.ExpSyn(0.5, sec = dend))
nc = h.NetCon(stim, a)
I cannot get the name (or type) of a (as an ExpSyn):

Code: Select all

>> a.__str__()
>> '<hoc.HocObject object at 0x892bef8>'

>> a.__repr__()
>> '<hoc.HocObject object at 0x892bef8>'

Strangely, "print a" gives

Code: Select all

>> print a
ExpSyn[3]
But redirect stdio doesn't work (doesn't give me a str 'ExpSyn[3]'), could HocObject, especially PointProcess object has an attribute that stores its own type/name?

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: pointprocess does not know its own type/name

Post by hines » Tue Aug 25, 2009 8:19 pm

you can work around the problem with

Code: Select all

s = h.ref('')
h.sprint(s, '%s', a)
print s[0]
you can put the idiom in a
def hocObjectName(hocobject):
and return a tuple of (classname, index) if you find that useful

hines
Site Admin
Posts: 1580
Joined: Wed May 18, 2005 3:32 pm

Re: pointprocess does not know its own type/name

Post by hines » Sat Aug 29, 2009 4:27 pm

See viewtopic.php?f=2&t=1759
In the future, one would find the type information for a HocObject instance with
a.hname()

Post Reply