Silencing Unwanted hoc Interpreter Text Output

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

Moderator: hines

Post Reply
gchadder3
Posts: 4
Joined: Fri May 28, 2010 5:05 pm

Silencing Unwanted hoc Interpreter Text Output

Post by gchadder3 »

I'm wondering if there is a way to silence the output of the hoc interpreter when running commands that avoids lines like
h('{the_command()}')

If I just do a
h.the_command()
then, depending on what the_command is, I will get hoc interpreter output text which clutters my simulation run outputs. Is there a run option or some other way of turning off hoc interpreter outputs from hoc commands called from the Python interpreter?
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Silencing Unwanted hoc Interpreter Text Output

Post by hines »

There is no way to turn it off from within hoc. All h.methods return a value. But h.method
embedded in a python program should have no output. Are you talking about commands
typed directly to the interpreter? To avoid the interpreter from printing the return value you can
use the idiom
a = h.method...
gchadder3
Posts: 4
Joined: Fri May 28, 2010 5:05 pm

Re: Silencing Unwanted hoc Interpreter Text Output

Post by gchadder3 »

Here's the line that causes the problem:

h.new_printlist_item(st_data, st_comment)

This is inside a Python script that is being run when I start a simulation by doing
nrngui -python sim.py
(sim.py being the main Python file). This simulation uses a lot of legacy hoc code and new_printlist_item() is actually a hoc function in one of the legacy hoc files. So it may be that hoc code called by new_printlist_item() is the problem, but I was hoping there might be some way of getting Python to not output hoc strings for whatever it calls. I think that if I did
h('{new_printlist_item(xxxx)}')
this would solve the problem for this line, but I want to avoid this clunky syntax when possible.

I just tried
ignore = h.new_printlist_item(st_data, st_comment)
and the call still printed out a 1, so that doesn't solve the problem here.
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Silencing Unwanted hoc Interpreter Text Output

Post by hines »

Oh. I see. That is a top level hoc statement executed when a hoc file is loaded. There is no way to avoid it except by
enclosing the offending statement in {}. It may be too extreme to temporarily set the stdout to /dev/null
http://www.neuron.yale.edu/neuron/stati ... #hoc_stdio
Post Reply