Python Forum
argv IndexError - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: argv IndexError (/thread-1253.html)



argv IndexError - hsunteik - Dec-18-2016

WuHere's my question link:

https://answers.yahoo.com/question/index?qid=20161218100154AAO3AKj
The following is what's contained in the link - Admin

i was trying to create a new programming language interpreter with python,but after just a few lines ,i tested it, i have this following error:
Error:
Traceback (most recent call last): File "C:\Users\User\Desktop\project teik\shortcut\codime interpreter\interpreter.py", line 11, in <module> run() File "C:\Users\User\Desktop\project teik\shortcut\codime interpreter\interpreter.py", line 8, in run open_file(argv[1]) IndexError: list index out of range
my current code:
from sys import argv 

def open_file(filename): 
   print(filename) 

def run(): 
   open_file(argv[1]) 

run()
note:the filename is test.codime and i put it in the same folder with this python project(the filename is interpreter.py)
Update: i have not started creating the lexer and parser yet.
Update 2: i am using the latest version of python
Update 3: just for your information, the new programming language name is codime.


RE: Python error - snippsat - Dec-18-2016

Look at my answer here.


RE: Python error - hsunteik - Dec-19-2016

thanks,you saved me .