Comments (5)
I submitted a patch to Python issue 9334 to
- accept negative scientific and complex numbers
- add the args_default_to_positional parser option
http://bugs.python.org/issue9334#msg184987
from argparse.
@hpaulj negative sentific floats now works. This fix does not cover complex numbers and values with leading dashes. I think, this can be safely postponed, until someone really needs it in real life.
from argparse.
I explored expanding the regex expression like this. Adding the exponential is easy. Adding complex makes the whole expression unwieldy. In the Python patch I chose instead to separate the two uses of _negativeNumberMatcher
.
For identifying negative like option strings I left the original matcher (examples are all simple ones like '-1', not even '-1.23', much less '-1.23e4'.)
For identifying real negative numbers, I chose instead to let Python's own number parser do the job:
if not self._has_negative_number_optionals:
try:
complex(arg_string)
return None
except ValueError:
pass
The javascript equivalent could use !isNaN(argString)
if (!_.any(this._hasNegativeNumberOptionals) && !isNaN(argString)) {
return null;
}
But since javascript does not have complex number type, expanding the regex to include exponentials should be just fine.
I've submitted a number of python argparse patches, but haven't gotten much feedback from their developers.
from argparse.
Yes, isNaN would be more simple. I didn't digged into algorythm, and just replaced existing regexp, after trebor89 pointed to bad line of code :) .
By the way, may be you have time to look into mincer project https://github.com/nodeca/mincer ? It has much more space for improvements, than argparse. I think, even in current state, argparse cover node developer's needs for 200% :) .
from argparse.
Argparse 2.0 was ported from scratch based on python 3.9.0. We aimed to keep source code as close as possible to the original, so this change didn't make it in.
Is it used by anybody? If so, maybe bug python developers again, issue still not resolved over there.
from argparse.
Related Issues (20)
- add_argument fails to fail when provided with invalid arguments HOT 1
- Implementation of default and required are inconsistent with Python implememtation. HOT 1
- Is there a way to generate a tab completions bash script? HOT 4
- v2 cannot be used with ts-node anymore HOT 2
- How to properly fix "nargs for store actions must be != 0" error? HOT 13
- add_parser with parents results in conflicting option for help HOT 9
- exit_on_error does not work, program still exit. HOT 1
- exit_on_error 'false' flag not respected when error in positional arguments HOT 2
- Node exception: syntax error in argparse.js: "syntax error: unexpected token {" HOT 1
- Question about the license change HOT 6
- Update to License of Python v2.0.1 HOT 4
- License not applicable? HOT 2
- Should the license be Python-2.0 or PSF-2.0? HOT 12
- Using in non-command line app? HOT 1
- How to make a custom Action? HOT 5
- TypeError: _StoreTrueAction() got an unexpected keyword argument 'metavar' HOT 1
- Please add defaultValue usage example HOT 9
- Coming from Commander
- ArgumentParser exits when met with an invalid argument
- npm packages out of sync: argparse and @types/argparse HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argparse.