Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not show output for assignment? #649

Closed
tbenst opened this issue Apr 15, 2018 · 2 comments
Closed

do not show output for assignment? #649

tbenst opened this issue Apr 15, 2018 · 2 comments

Comments

@tbenst
Copy link

tbenst commented Apr 15, 2018

In IPython, something like x = np.arange(1000) shows no output, whereas in IJulia x = collect(1:1000) does. I understand this matches the REPL, but is there a way to surpress this by default other than adding semicolons everywhere?

@stevengj
Copy link
Member

No. When you evaluate a cell in IJulia, it is just returns the value of the last expression, and what you are seeing here is a difference between the Julia and Python languages.

In Python, assignment expressions don't have a value, whereas in Julia the assignment x = y has the value y.

(In IPython, they added support for showing the result of an assignment, but they had to do it by hacking the AST because of the abovementioned Python language behavior: ipython/ipython#10598)

@jlumpe
Copy link
Contributor

jlumpe commented Feb 26, 2019

Wow, I didn't know about the semicolon method, I've just been adding nothing to a line the end of my cells.

@stevengj I do think this could be a very useful feature, maybe enabled by a configuration option that is disabled by default. I don't think the differences in the two languages are very important here, it's just more about what is most useful/convenient to the user of the notebook. Pretty-printing even small arrays take up a lot of vertical space (one line per element) and make the notebook significantly less readable (which is one of the main selling points of the notebook in the first place) if those values aren't important.

Personally I think at least 90% of the time I'm not interested in seeing the value of the assignment at the end of the cell, so it would make a lot of sense to have an option to disable it by default. For the minority of times I do want it I could just do what I do in IPython which very simple:

...
x = somevalue
x

It seems like this shouldn't be too difficult to add, it looks like there's already a manual check for the semicolon at the end of the line that sets a silent variable:

silent = silent || REPL.ends_with_semicolon(code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants