forked from ovh/pci-test
fix/improvement to python files
This commit is contained in:
parent
cd81e92142
commit
012b0bf04c
4
ex1/a.py
4
ex1/a.py
@ -1,4 +1,4 @@
|
||||
import sys
|
||||
|
||||
frase = " ".join(sys.argv[1:])
|
||||
print("Hai scritto:", frase)
|
||||
argv = " ".join(sys.argv[1:])
|
||||
print("You've written:", argv)
|
||||
|
12
ex1/b.py
12
ex1/b.py
@ -1,25 +1,25 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
VALORI_AMMESSI = {"toto", "tata", "titi"}
|
||||
vars = {"toto", "tata", "titi"}
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--target',
|
||||
nargs='+',
|
||||
choices=VALORI_AMMESSI,
|
||||
help="Specifica da 1 a 3 valori tra: toto, tata, titi.",
|
||||
choices=vars,
|
||||
help="Specify from 1 to 3 values from: toto, tata, titi.",
|
||||
required=True
|
||||
)
|
||||
|
||||
# Esegui parsing
|
||||
# Execute parsing
|
||||
args = parser.parse_args()
|
||||
|
||||
# Verifica massimo 3 valori
|
||||
if len(args.target) > 3:
|
||||
print("Errore: puoi fornire **al massimo 3** valori tra 'toto', 'tata' e 'titi'.", file=sys.stderr)
|
||||
print("Error: can be used **at max 3** values from 'toto', 'tata' and 'titi'.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# Tutto OK
|
||||
print("Valori accettati:", args.target)
|
||||
print("You've written:", args.target)
|
||||
|
6
ex1/c.py
6
ex1/c.py
@ -2,9 +2,9 @@ import sys
|
||||
import pyfiglet
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Usa: python script.py 'testo da convertire'")
|
||||
print("Usage: python script.py 'text to be converted'")
|
||||
sys.exit(1)
|
||||
|
||||
text = " ".join(sys.argv[1:])
|
||||
ascii_art = pyfiglet.figlet_format(text)
|
||||
print(ascii_art)
|
||||
f = pyfiglet.figlet_format(text)
|
||||
print(f)
|
||||
|
Loading…
Reference in New Issue
Block a user