google / google/python-fire

How to parse list of integers

オープン
#624 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
28.2k
フォーク
1.5k
PR マージ指標
30日以内にマージされた PR はありません

説明

With argparse, you can do:
```
> python example.py --this 123
> python example.py --this 123 456
> python example.py --this 123 456 789
```
With Fire, how do you parse a list of integers (including a single element list) like argparse?

```
# example.py
import fire

def main(this: list[int]):
print(type(this), this)

if __name__ == '__main__':
fire.Fire(main)
```
```
> python example.py --this 123
123

> python example.py --this 123 456
ERROR: Could not consume arg: 456

> python example.py --this 123 456 789
ERROR: Could not consume arg: 456
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。