Skip to content

Add argparse to make it more pythonic #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

managedkaos
Copy link
Contributor

Get help:

22:05 $ ./hackernews.py -h
usage: hackernews.py [-h] [int]

positional arguments:
  int         Then number of news items to return, from 1 to 30

optional arguments:
  -h, --help  show this help message and exit

Default is 10:

22:08 $ ./hackernews.py
1. Video Games Are Destroying the People Who Make Them
https://www.nytimes.com/2017/10/25/opinion/work-culture-video-games-crunch.html

2. Microsoft Has Stopped Manufacturing The Kinect
https://www.fastcodesign.com/90147868/exclusive-microsoft-has-stopped-manufacturing-the-kinect
...

Get more than 10:

22:08 $ ./hackernews.py 20

But you can only get 30:

22:08 $ ./hackernews.py 31
usage: hackernews.py [-h] [int]
hackernews.py: error: argument int: invalid choice: 31 (choose from 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant