w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Error executing python scripts

You do not execute a script calling the function display("Lary", 43, "M")

you use python my_script.py from bash or ./my_script.py

You are getting a bash error not a python error, to make a python script executable you just need chmod +x my_script.py.

~$ display("Lary", 43, "M")
bash: syntax error near unexpected token `"Lary",'

my_script.py:

import sys

def display(name, age, sex):
  print "Name: ", name
  print "Age: ", age
  print "Sex: ", sex
name = sys.argv[1]
age = sys.argv[2]
sex = sys.argv[3]
display(name, age, sex)

~$ python my_script.py foo 43 male
Name:  foo
Age:  43
Sex:  male




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.