Skip to content

Commit

Permalink
kyclark#1 joy.y
Browse files Browse the repository at this point in the history
  • Loading branch information
joy committed Oct 1, 2021
1 parent 8b49d04 commit 7d819f3
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 21 deletions.
22 changes: 1 addition & 21 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,4 @@ tex2pdf*
.log
.coverage
.idea
.vscode
02_crowsnest/crowsnest.py
03_picnic/picnic.py
04_jump_the_five/jump.py
05_howler/howler.py
06_wc/wc.py
07_gashlycrumb/gashlycrumb.py
08_apples_and_bananas/apples.py
09_abuse/abuse.py
10_telephone/telephone.py
11_bottles_of_beer/bottles.py
12_ransom/ransom.py
13_twelve_days/twelve_days.py
14_rhymer/rhymer.py
15_kentucky_friar/friar.py
16_scrambler/scrambler.py
17_mad_libs/mad.py
18_gematria/gematria.py
19_wod/wod.py
20_password/password.py
21_tictactoe/tictactoe.py
.vscode
29 changes: 29 additions & 0 deletions 01_hello/hello.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
"""
Author: NowHappy <[email protected]>
Purpose: Say Hello
"""

import argparse


# ---------------------------------------------------
def get_args():
"""Get the command-line arguments"""
parser = argparse.ArgumentParser(description='Say Hello')
parser.add_argument('-n', '--name', metavar='name',
default='World', help='Name to greet')

return parser.parse_args()


# ---------------------------------------------------
def main():
"""happy now"""
args = get_args()
print('Hello, ' + args.name + '!')


# ---------------------------------------------------
if __name__ == '__main__':
main()
72 changes: 72 additions & 0 deletions 01_hello/hello2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""
Author : kakao <kakao@localhost>
Date : 2021-09-28
Purpose: Rock the Casbah
"""

import argparse


# --------------------------------------------------
def get_args():
"""Get command-line arguments"""

parser = argparse.ArgumentParser(
description='Rock the Casbah',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('positional',
metavar='str',
help='A positional argument')

parser.add_argument('-a',
'--arg',
help='A named string argument',
metavar='str',
type=str,
default='')

parser.add_argument('-i',
'--int',
help='A named integer argument',
metavar='int',
type=int,
default=0)

parser.add_argument('-f',
'--file',
help='A readable file',
metavar='FILE',
type=argparse.FileType('rt'),
default=None)

parser.add_argument('-o',
'--on',
help='A boolean flag',
action='store_true')

return parser.parse_args()


# --------------------------------------------------
def main():
"""Make a jazz noise here"""

args = get_args()
str_arg = args.arg
int_arg = args.int
file_arg = args.file
flag_arg = args.on
pos_arg = args.positional

print(f'str_arg = "{str_arg}"')
print(f'int_arg = "{int_arg}"')
print('file_arg = "{}"'.format(file_arg.name if file_arg else ''))
print(f'flag_arg = "{flag_arg}"')
print(f'positional = "{pos_arg}"')


# --------------------------------------------------
if __name__ == '__main__':
main()
72 changes: 72 additions & 0 deletions 01_hello/hello3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""
Author : kakao <kakao@localhost>
Date : 2021-09-28
Purpose: Rock the Casbah
"""

import argparse


# --------------------------------------------------
def get_args():
"""Get command-line arguments"""

parser = argparse.ArgumentParser(
description='Rock the Casbah',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('positional',
metavar='str',
help='A positional argument')

parser.add_argument('-a',
'--arg',
help='A named string argument',
metavar='str',
type=str,
default='')

parser.add_argument('-i',
'--int',
help='A named integer argument',
metavar='int',
type=int,
default=0)

parser.add_argument('-f',
'--file',
help='A readable file',
metavar='FILE',
type=argparse.FileType('rt'),
default=None)

parser.add_argument('-o',
'--on',
help='A boolean flag',
action='store_true')

return parser.parse_args()


# --------------------------------------------------
def main():
"""Make a jazz noise here"""

args = get_args()
str_arg = args.arg
int_arg = args.int
file_arg = args.file
flag_arg = args.on
pos_arg = args.positional

print(f'str_arg = "{str_arg}"')
print(f'int_arg = "{int_arg}"')
print('file_arg = "{}"'.format(file_arg.name if file_arg else ''))
print(f'flag_arg = "{flag_arg}"')
print(f'positional = "{pos_arg}"')


# --------------------------------------------------
if __name__ == '__main__':
main()
72 changes: 72 additions & 0 deletions 01_hello/hello4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""
Author : NowHappy <[email protected]>
Date : 2021-09-28
Purpose: Rock the Casbah
"""

import argparse


# --------------------------------------------------
def get_args():
"""Get command-line arguments"""

parser = argparse.ArgumentParser(
description='Rock the Casbah',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('positional',
metavar='str',
help='A positional argument')

parser.add_argument('-a',
'--arg',
help='A named string argument',
metavar='str',
type=str,
default='')

parser.add_argument('-i',
'--int',
help='A named integer argument',
metavar='int',
type=int,
default=0)

parser.add_argument('-f',
'--file',
help='A readable file',
metavar='FILE',
type=argparse.FileType('rt'),
default=None)

parser.add_argument('-o',
'--on',
help='A boolean flag',
action='store_true')

return parser.parse_args()


# --------------------------------------------------
def main():
"""Make a jazz noise here"""

args = get_args()
str_arg = args.arg
int_arg = args.int
file_arg = args.file
flag_arg = args.on
pos_arg = args.positional

print(f'str_arg = "{str_arg}"')
print(f'int_arg = "{int_arg}"')
print('file_arg = "{}"'.format(file_arg.name if file_arg else ''))
print(f'flag_arg = "{flag_arg}"')
print(f'positional = "{pos_arg}"')


# --------------------------------------------------
if __name__ == '__main__':
main()

0 comments on commit 7d819f3

Please sign in to comment.