google / google/python-fire

Output of the example for grouping in docs is wrong

未关闭
#333 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
28.2k
派生
1.5k
PR 合并指标
30 天内没有已合并 PR

描述

Hello.

In the Group Commands section (https://github.com/google/python-fire/blob/master/docs/guide.md#grouping-commands), the example code is

```python
class IngestionStage(object):

def run(self):
return 'Ingesting! Nom nom nom...'

class DigestionStage(object):

def run(self, volume=1):
return ' '.join(['Burp!'] * volume)

def status(self):
return 'Satiated.'

class Pipeline(object):

def __init__(self):
self.ingestion = IngestionStage()
self.digestion = DigestionStage()

def run(self):
self.ingestion.run()
self.digestion.run()
return 'Pipeline complete'

if __name__ == '__main__':
fire.Fire(Pipeline)
```

and according to the guide

```bash
$ python example.py run
Ingesting! Nom nom nom...
Burp!
```

However, the output is wrong. It should be

```bash
$ python example.py run
Pipeline complete
```

This can be easily fixed.
However, in order to demonstrate the pipeline functionality, I would suggest to change the example to

```python
class IngestionStage(object):

def run(self):
return 'Ingesting! Nom nom nom...'

class DigestionStage(object):

def run(self, volume=1):
return ' '.join(['Burp!'] * volume)

def status(self):
return 'Satiated.'

class Pipeline(object):

def __init__(self):
self.ingestion = IngestionStage()
self.digestion = DigestionStage()

def run(self):
ingestion_output = self.ingestion.run()
digestion_output = self.digestion.run()
return ingestion_output + digestion_output

if __name__ == '__main__':
fire.Fire(Pipeline)
```

and accordingly the output should be

```bash
$ python example.py run
Ingesting! Nom nom nom...Burp!
```

I would like to know which change @dbieber would like.
Thank you.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。