Why the value returned by read_data,open... are unavailable in Jupyter notebook

asked 2017-04-24 15:35:45 +0200

danny gravatar image

updated 2017-04-24 15:50:12 +0200

I run the following commands in code cell of jupyternotebook.

indata = tmp_filename()
 f = open(indata, "w")
 f.write("17\n42\n")
 f.close()
 l = read_data(indata, ZZ); l

And I get the following error message:

TypeError: 'NoneType' object is not iterable

But the result is output in terminal.

[I 21:15:07.797 NotebookApp] Saving file at /Untitled.ipynb
[17, 42]

How to solve this problem?

By the way: some functions such as "print", "tmp_filename" also can not output in Jupter notebook. These functions work well in old sage math notebook.

edit retag flag offensive close merge delete

Comments

There is an obvious indent error, but i suppose it comes from manually indenting 5 (and not 4) spaces the markdown message. Instead of using the pictogram with

101
010

and in my case the five lines work in jupyter notebook. I'we got (with deprecation warnings):

[I 00:11:19.965 NotebookApp] Saving file at /w123456789.ipynb
[I 00:11:36.920 NotebookApp] Saving file at /w123456789.ipynb
[I 00:13:02.667 NotebookApp] Saving file at /w123456789.ipynb

and the print was also working. I would try the same with a specific file name, then try to see if the file was written:

filename =  '/home/dan/abcd.txt'
f = open( filename, 'w' )
f.write( '17\n42\n' )
f.close()
l = read_data( filename,  ZZ ); l

And indeed my home dir got the file with the content:

17
42
dan_fulea gravatar imagedan_fulea ( 2017-04-25 00:18:23 +0200 )edit