ticoneva / pystata-kernel

Jupyter kernel for Stata based on pystata
GNU General Public License v3.0
13 stars 6 forks source link

Add echo='None' functionality via program definition #15

Closed hugetim closed 2 years ago

hugetim commented 2 years ago

Addresses #4

Looking for a simple way to suppress echo of commands for multi-command code blocks, I discovered a workaround:

  1. quietly pass the code to STATA as a program definition, and
  2. then run that program as a single-line command (with echo=False).

This seems to give the desired result, displaying any output without echoing the commands.

ticoneva commented 2 years ago

That's an interesting suggestion. I tried the code after replacing the tabspace with whitespace, and I see two issues:

  1. This method works for \\\ but not #delimit ;. It appears that the latter is not permitted inside program definition, so another solution will be needed for that.
  2. A more critical issue is, it is no longer possible to define new programs in the notebook, since Stata does not allow nested program define.
hugetim commented 2 years ago

Wow, thank you for testing it out so quickly. I don't see any immediate way around those issues, which probably outweigh the benefit. But perhaps we could instead add a magic with this functionality? Something like *%no_echo at the top of a block? (I've never coded a magic myself, though.)