[Tutor] Argparse Error

Alan Gauld alan.gauld at yahoo.co.uk
Sun Aug 12 13:24:51 EDT 2018


On 12/08/18 16:52, Nathan Johnson wrote:
> Okay so I downloaded and saved the script as a .py file in a folder named
> Python on the D; Drive, and also moved my video file to a folder in my D:
> drive with the name Video. I tried using it in Command Prompt, Python, and
> Python IDLE, but I got the same error saying
> 
> SyntaxError: unexpected character after line continuation character

This is a Python error. I suspect you only get this when trying
to run it from IDLE or inside the Python interpreter. Not from
the OS command prompt? Its caused by the \ characters which
Python sees as line continuation characters.

But you should always send us the complete error message not
just the last line. Although it looks like gobbldegook it is
actually full of useful data.

But for now I suspect this is all irrelevant to your problem.
Instead follow the suggestion below...

> I know this is probably user error, but I am a complete novice so I need a
> little more explanation than "provide a file argument" please. I need to
> know how exactly to implement the file argument you provided. 

An "argument" is just the value that you give to a command.
So a file argument is just the path to a file. You need to
provide that when you execute the command.

That's what I was showing you here:

>> C:\WINDOWS\PROMPT> python D:\Python\myscript.py D:\Image\myfile.img

It says:

Use the Windows CMD prompt and

Type

python

followed by

the path to your script file

followed by

the path to your image/video file

The last bit (or lack of) is what will generate the file error.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list