Python to hoc

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

Moderator: hines

Post Reply
shyam_u2
Posts: 77
Joined: Sun Feb 20, 2011 7:15 pm

Python to hoc

Post by shyam_u2 » Thu Feb 02, 2017 6:36 pm

Can some one tell me the hoc version of this python code ?

Code: Select all

		self.Adend1.connect(self.soma,   0.5, 0)
Thanks in advance,
S

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python to hoc

Post by ted » Fri Feb 03, 2017 12:08 am

shyam_u2 wrote:Can some one tell me the hoc version of this python code
A zen master might be able to. I can only say that the statement is a python statement, not a hoc statement.

ted
Site Admin
Posts: 5591
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Python to hoc

Post by ted » Fri Feb 03, 2017 12:20 am

Sorry, I really am dense sometimes. I have been wrestling with a problem that involved code versioning, so when you asked a question about "version" I took it to mean something related to version numbers. But more likely you were asking what the equivalent hoc statement might be.

The python statement
foo.connect(bar, 0.5, 0)
would connect the 0 end of a (child) section called foo to the 0.5 location (midpoint) of a (parent) section called bar.
The "self" keyword is used inside of a block of python code that defines a new object class, to refer to things that belong to an instance of that class. A statement of the form
self.foo.connect(self.bar, 0.5, 0)
means that an instance of the class will have two sections foo and bar where foo is a child of bar and foo's 0 end is attached to the middle of bar.

hoc templates allow definition of new cell classes made out of sections that are connected to each other, but without having to use the "self" keyword. The easiest way to generate a very clean, bug-free and well-organized cell class definition in hoc is to use the CellBuilder to construct a model cell, then export a new cell class from the CellBuilder. There is no equivalent tool for python, which is too bad, because users must then depend on their own programming skills and programming styles, and the results are not always pretty.

Post Reply