[New-bugs-announce] [issue34803] argparse int type does not accept scientific notation

Jesse Hostetler report at bugs.python.org
Tue Sep 25 18:31:02 EDT 2018


New submission from Jesse Hostetler <jessehostetler at gmail.com>:

The 'argparse' module gives a parse error for integer arguments written in scientific notation. I would expect this to work, since integers can be constructed from literals in scientific notation.

Example (also attached):

import argparse
foo = int(1e3) # Works: foo = 1000
parser = argparse.ArgumentParser()
parser.add_argument( "--foo", type=int )
parser.parse_args( ["--foo=1e3"] )
# error: argument --foo: invalid int value: '1e3'

----------
components: Library (Lib)
files: argparse-int-scientific.py
messages: 326409
nosy: jessehostetler
priority: normal
severity: normal
status: open
title: argparse int type does not accept scientific notation
type: enhancement
versions: Python 3.7
Added file: https://bugs.python.org/file47824/argparse-int-scientific.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34803>
_______________________________________


More information about the New-bugs-announce mailing list