Suppress output when loading hoc file using h(xopen(''))

Anything that doesn't fit elsewhere.
Post Reply
landoskape
Posts: 11
Joined: Sat Oct 17, 2020 3:08 pm

Suppress output when loading hoc file using h(xopen(''))

Post by landoskape »

I'm running an optimization that requires me to reload cells frequently. Everytime I do so it outputs a "1" to the screen (I'm working in jupyter lab). How do I suppress this?

I'm loading a .hoc file by using the following line:

Code: Select all

h('xopen("./filename.hoc")');
Thanks for your assistance
landoskape
Posts: 11
Joined: Sat Oct 17, 2020 3:08 pm

Re: Suppress output when loading hoc file using h(xopen(''))

Post by landoskape »

For anyone bothered by this: here's a python specific solution:

Code: Select all

from contextlib import contextmanager
import sys, os

@contextmanager
def suppress_stdout():
    with open(os.devnull, "w") as devnull:
        old_stdout = sys.stdout
        sys.stdout = devnull
        try:  
            yield
        finally:
            sys.stdout = old_stdout

with suppress_stdout():
	h('xopen("./filename.hoc")');            
Post Reply