How to use sys.argv?

Hello I am trying to write a function which will take different argument and
would be used in another function in another script. My idea is to be able to precise a parameter directly from the terminal and the script will somewhat go the function with the precise parameter and Apply the correct line.

So I run my script like this and put f which is my parameter but I do not have any answer , below the full script.

C:\Users\Etu\ocuments>python f  

first script

import sys

first_arg = sys.argv[1]

texte = "je MaNgE"

def get_command(texte, first_arg):
    if first_arg =="f":
        texte = texte.lower()
        return texte
    elif first_arg=="t":
        return texte.split()
    elif first_arg =="r":

    return texte

        raise Exception("Wrongfile feature type entered. Possible values: 't','f', 'r")

second script

from test import *

texte = "je MaNgE"

def choose (texte):
    texte=get_command(texte, first_arg)


The idea is to modify directly the parameter from the shell without going Inside the script all the time.

Leave a Reply

Your email address will not be published. Required fields are marked *