New submission from Arman Sargsyan :
URL - https://docs.python.org/3/howto/argparse.html
The following code will return a type error:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("square", help="display a square of a given number")
args = parser.parse_args()
print(args.square**2)
This should be changed to:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("square", help="display a square of a given number")
args = parser.parse_args()
print(int(args.square)**2)
--
components: Parser
messages: 395963
nosy: arsar7, lys.nikolaou, pablogsal
priority: normal
pull_requests: 25349
severity: normal
status: open
title: argparser documentation error
type: resource usage
versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python
3.9
___
Python tracker
<https://bugs.python.org/issue44438>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com