Page 1 of 1
accessing hoc from python
Posted: Wed Apr 04, 2012 3:27 am
by stil
I have this 'bug' when using python : If ido
, and then
, the variables written in the hoc file like
will be seen as 0.
If i change for
, or if i import
, and adapt the code accordingly, the hoc variables are not ceiled.
regards
Re: accessing hoc from python
Posted: Wed Apr 04, 2012 3:36 pm
by ted
Have you read the Programmer's Reference material on Python_accessing_hoc ?
http://www.neuron.yale.edu/neuron/stati ... essing_Hoc
Re: accessing hoc from python
Posted: Wed Apr 04, 2012 6:16 pm
by stil
thanks for the link ted, i just realize that there is a dedicated section in the programmers' reference.
I used documentations in
http://www.davison.webfactional.com/not ... oc-python/, somehow kept using a regular hoc file for all the model description, and used python for all the surrounding tasks (simulation control, plotting)...
What i mentionned can be easily worked-around, but i was wondering the reason for this behavior. Do you suggest to write 'everything' in the same language, to make a choice between hoc and python ... ?
thanks again, anyway.
Re: accessing hoc from python
Posted: Wed Apr 04, 2012 9:24 pm
by ted
That's fine. Just remember that a variable whose name in hoc is x will be called h.x in Python.
Do you suggest to write 'everything' in the same language, to make a choice between hoc and python
Not at all. Just pointing out that, if you want to use Python to refer to a variable that was created by a hoc statement, there is a way to do that. For example, if there is a hoc statement like
x = 0.001
then in Python
h.x
will have the value 0.001, but there may or may not be a Python variable called x, and even if there is one, it won't have anything to do with the hoc variable called x.