I tried to create a python class, that should create an instance of neuron:
Here a very simple example:
class neuron():
def __init__(self, tstop):
import neuron
self.h = neuron.h
self.h("tstop = %d"%tstop)
n1 = neuron(100)
n2 = neuron(500)
print n1.h.tstop
print n2.h.tstop
I expected that once a new object is created also a new neuron object will be created.. The neuron.h variable however seems to be kind of global: the result of this script ist:
500.0
500.0
Is it possible to create different hoc objects that do not see each other??
Thank you,
Armin
Two instances of Neuron in a Python script
Moderator: hines
Re: Two instances of Neuron in a Python script
Modules in python are singleton. Therefore, all references made in a running program are to the same module.
As a result, neuron.h is one and the same object each time you import it in the constructor.
As a result, neuron.h is one and the same object each time you import it in the constructor.