-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathget_args.py
More file actions
35 lines (25 loc) · 782 Bytes
/
get_args.py
File metadata and controls
35 lines (25 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#Author: NerdOfCode
#Tested on Ubuntu Server 17.04
#Python v--> Works on latest 3.x version
#Documentation: I recommend importing this file then calling function
#get_args into a variable then print the value of that variable
import sys, os
#For filesake purposes
######################
max_arg=10 #
arguements=[] #
######################
#print(sys.argv[1])
def get_args():
length=len(sys.argv)
if length > max_arg:
return "Too many arguements... Goodbye"
sys.exit(1)
for argu in range(length):
arguements.append(sys.argv[argu])
if sys.argv[0]:
del arguements[0]
return arguements
#Example of call and printing args
values=get_args()
print(values)