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

double newline from %loadpy in python notebook (at least on mac) #1204

Closed
piti118 opened this issue Dec 24, 2011 · 3 comments · Fixed by #1207
Closed

double newline from %loadpy in python notebook (at least on mac) #1204

piti118 opened this issue Dec 24, 2011 · 3 comments · Fixed by #1207
Milestone

Comments

@piti118
Copy link
Contributor

piti118 commented Dec 24, 2011

I suspect that it double count /r/n as two new lines. When I use %loadpy from python notebook(from stable 0.12) I expect something like

import pickle
from itertools import product
#get tmp.pck from prepareplotdata.py
f = open('tmp.pck')
m = pickle.load(f)

But I got something like

import pickle

from itertools import product

#get tmp.pck from prepareplotdata.py

f = open('tmp.pck')

m = pickle.load(f)
@piti118
Copy link
Contributor Author

piti118 commented Dec 24, 2011

Up on closer inspection it is the server side this is what I got Notebook.handle_shell_reply in e.data

{"parent_header":
  {"username":"username","msg_id":"49C2620FD9F34A4FAD75D5655CC7415E",
  "msg_type":"execute_request",
  "session":"439FD9883D22482098055D869FC61668"},
"msg_type":"execute_reply",
"msg_id":"a7f8a644-4959-470b-bedf-cdb7fdc58e90",
"content":
  {"status":"ok",
   "execution_count":10,
   "user_variables":{},
   "payload":
      [{"text":"#single new line after this\n\n#double new line after this\n\n\n\n#triple newline after this\n\n\n\n\n\n#no newline at the end",
       "source":"IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input"}],
   "user_expressions":{}},
"header":
  {"username":"kernel",
   "session":"e49e9d26-4fdc-419d-b51d-364299bdc070",
   "msg_id":"a7f8a644-4959-470b-bedf-cdb7fdc58e90",
   "msg_type":"execute_reply"}
}

1 new line got converted into 2 new lines
2 new lines got converted into 4 new lines
3 new lines got converted into 6 new lines

@minrk
Copy link
Member

minrk commented Dec 24, 2011

Argh - I know exactly what caused this, and it it affects %loadpy from local files in all contexts. See PR #1207 for a fix.

@piti118
Copy link
Contributor Author

piti118 commented Dec 24, 2011

Thanks that does the job :)

@piti118 piti118 closed this as completed Dec 24, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants