Python Forum
Something So Basic It is Embarrassing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Something So Basic It is Embarrassing
#1
I am a brand new learner of python.

I created a text file named 'hello.py' and the content of the file is print('Hello'). It resides on my hard drive in folder C:\python.

I want to import and run this file in Python 3.7.2 Shell. When I type in C:\python hello.py or C:\\python hello.py I get the following message - SyntaxError: unexpected character after line continuation character.

What am I doing wrong? This seems like something so simple I am embarrassed to even write about it.

Thanks
Reply
#2
show actual contents of hello.py file (in code tags)
Reply
#3
It looks like you try to run the file from python interactive shell. You need to run it from cmd.
Check this tutorial https://python-forum.io/Thread-How-to-Ex...ython-code
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
Thank you for your reply and your willingness to help.

Sorry, but I don't know what a code tag is. however, the content of the file hello.py is print('Hello').
Reply
#5
(Jan-31-2019, 02:42 PM)Newsome Wrote: Sorry, but I don't know what a code tag is.
Read all of the Help/Rules section and particularly https://python-forum.io/misc.php?action=help&hid=25
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(Jan-31-2019, 02:36 PM)Newsome Wrote: I want to import and run this file in Python 3.7.2 Shell.

Python has an interactive interpreter. You can read from Python documentation how to Invoke the Interpeter.

If you want to run file from terminal/command line you should read Command line and evironment

If you want import file into Python interpreter you should read Modules
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#7
from command line (change directory to hello.py script location):
python hello.py
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020