[issue34803] argparse int type does not accept scientific notation

2018-09-25 Thread Jesse Hostetler


Jesse Hostetler  added the comment:

I suppose desired behavior would be to accept the argument only if it can be 
converted to int without loss of information.

--

___
Python tracker 
<https://bugs.python.org/issue34803>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue34803] argparse int type does not accept scientific notation

2018-09-25 Thread Jesse Hostetler


New submission from Jesse Hostetler :

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 
<https://bugs.python.org/issue34803>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com