-
Notifications
You must be signed in to change notification settings - Fork 7
/
ud.py
36 lines (34 loc) · 767 Bytes
/
ud.py
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=@blank_x
#!/usr/bin/python3
import sys, urbandict, urllib
if len(sys.argv) >= 2:
if len(sys.argv) == 2:
tud=sys.argv[1]
else:
ttud=' '.join(sys.argv)
tttud=len(sys.argv[0]) + 1
tud=ttud[tttud:]
else:
tud=input('What to look up? ')
langi='en'
wasfine=True
httper=False
try:
mean=urbandict.define(tud)
except urllib.error.HTTPError:
wasfine=False
httper=True
except:
wasfine=False
if wasfine == True:
print('Meaning of ' + tud + ':')
print(mean[0]['def'])
print('\nNow for some (probably useless) examples:')
print(mean[0]['example'])
else:
if httper == False:
print('An error occured.')
print('Now deal with this very informative error message.')
else:
print('I got an HTTP Error!')
print(tud + ' probably doesn\'t even exist.')