1

I am trying to convert an IPython/Jupyter notebook into a Python executable script and I've got it working for the most part but I have some instances where I would have, for example,

a = [1,2,3]
a

or

s = 'some string'
type(s)

Now, left as is in a Python script will not print the variable "a" and will not display the output of "type(s)" if I run

python myscript.py

in the terminal (in most cases). I tried using the built-in print function but sometimes it'll only display

<built-in .... >

which is not what I want.

I'm not sure if what I am asking is possible but I would like it to run the Python code above in the terminal as it would when I run it in a cell in IPython or Jupyter notebook. The reason for writing this conversion script is because it was assigned as a homework exercise to be completed and I would appreciate any hints on doing this. Just to be clear, I don't think this is a required for the assignment as the instructor never mentioned it in class, but I am just curious.

1 Answer 1

1

To have the script print out, you'll need to explicitly use the print function. Eg,

a = [1,2,3]
print(a)
s = 'some string'
print(type(s))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.