Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6958018

Browse files
author
joy
committedOct 7, 2021
kyclark#9 joy.y
1 parent 5ce2d01 commit 6958018

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
 

‎09_abuse/abuse.py

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Author : NowHappy <rlfmalehd@gmail.com>
4+
Date : 2021-10-07
5+
Purpose: Heap abuse
6+
"""
7+
8+
import argparse
9+
import random
10+
11+
12+
# --------------------------------------------------
13+
def get_args():
14+
"""Get command-line arguments"""
15+
16+
parser = argparse.ArgumentParser(
17+
description='Heap abuse',
18+
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
19+
20+
parser.add_argument('-a',
21+
'--adjectives',
22+
help='Number of adjectives',
23+
metavar='adjectives',
24+
type=int,
25+
default=2)
26+
27+
parser.add_argument('-n',
28+
'--number',
29+
help='Number of insults',
30+
metavar='insults',
31+
type=int,
32+
default=3)
33+
34+
parser.add_argument('-s',
35+
'--seed',
36+
help='Random seed',
37+
metavar='seed',
38+
type=int,
39+
default=None)
40+
41+
args = parser.parse_args()
42+
43+
if args.adjectives < 1:
44+
parser.error(f'--adjectives "{args.adjectives}" must be > 0')
45+
46+
if args.number < 1:
47+
parser.error(f'--number "{args.number}" must be > 0')
48+
49+
return args
50+
51+
52+
# --------------------------------------------------
53+
def main():
54+
"""Make a jazz noise here"""
55+
56+
args = get_args()
57+
random.seed(args.seed) # 해당 라인 주석 처리하면 완전 램덤, 무작위성을 제어하기 위해 설정. (유사 무작위 : seed를 사용해서 무작위성을 제어)
58+
59+
adjective_list = '''bankrupt base caterwauling corrupt cullionly detestable dishonest false
60+
filthsome filthy foolish foul gross heedless indistinguishable infected
61+
insatiate irksome lascivious lecherous loathsome lubbery old peevish
62+
rascaly rotten ruinous scurilous scurvy slanderous sodden-witted
63+
thin-faced toad-spotted unmannered vile wall-eyed'''.split()
64+
65+
noun_list = '''Judas Satan ape ass barbermonger beggar block boy braggart butt
66+
carbuncle coward coxcomb cur dandy degenerate fiend fishmonger fool
67+
gull harpy jack jolthead knave liar lunatic maw milksop minion
68+
ratcatcher recreant rogue scold slave swine traitor varlet villain worm'''.split()
69+
70+
for _ in range(args.number):
71+
print(f'You {", ".join(random.sample(adjective_list, args.adjectives))} {random.choice(noun_list)}!')
72+
73+
74+
# --------------------------------------------------
75+
if __name__ == '__main__':
76+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.