V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  zengshusen  ›  全部回复第 3 页 / 共 4 页
回复总数  64
1  2  3  4  
2017-03-09 12:39:39 +08:00
回复了 cococoder 创建的主题 前端开发 最近在追一前端妹子,要生日了,不知道送啥礼物好
送她 shadowsocks 账号
Acer 的评论也精彩
很好奇大姐姐站
2017-03-04 23:32:47 +08:00
回复了 zgqq 创建的主题 Linux 有没有大佬用 archlinux 工作的?
执行 pacman -Rsc 挂了
2017-03-03 15:23:33 +08:00
回复了 vnady 创建的主题 问与答 哥老关,翻墙也打不开 googleblog.com, why?
Open Source Blog
News about Google's open source student programs and software releases
Introducing Python Fire, a library for automatically generating command line interfaces
Thursday, March 2, 2017
Today we are pleased to announce the open-sourcing of Python Fire. Python Fire generates command line interfaces (CLIs) from any Python code. Simply call the Fire function in any Python program to automatically turn that program into a CLI. The library is available from pypi via `pip install fire`, and the source is available on GitHub.
Python Fire will automatically turn your code into a CLI without you needing to do any additional work. You don't have to define arguments, set up help information, or write a main function that defines how your code is run. Instead, you simply call the `Fire` function from your main module, and Python Fire takes care of the rest. It uses inspection to turn whatever Python object you give it -- whether it's a class, an object, a dictionary, a function, or even a whole module -- into a command line interface, complete with tab completion and documentation, and the CLI will stay up-to-date even as the code changes.
To illustrate this, let's look at a simple example.
#!/usr/bin/env python
import fire

class Example(object):
def hello(self, name='world'):
"""Says hello to the specified name."""
return 'Hello {name}!'.format(name=name)

def main():
fire.Fire(Example)

if __name__ == '__main__':
main()
When the Fire function is run, our command will be executed. Just by calling Fire, we can now use the Example class as if it were a command line utility.
$ ./example.py hello
Hello world!
$ ./example.py hello David
Hello David!
$ ./example.py hello --name=Google
Hello Google!
Of course, you can continue to use this module like an ordinary Python library, enabling you to use the exact same code both from Bash and Python. If you're writing a Python library, then you no longer need to update your main method or client when experimenting with it; instead you can simply run the piece of your library that you're experimenting with from the command line. Even as the library changes, the command line tool stays up to date.
At Google, engineers use Python Fire to generate command line tools from Python libraries. We have an image manipulation tool built by using Fire with the Python Imaging Library, PIL. In Google Brain, we use an experiment management tool built with Fire, allowing us to manage experiments equally well from Python or from Bash.
Every Fire CLI comes with an interactive mode. Run the CLI with the `--interactive` flag to launch an IPython REPL with the result of your command, as well as other useful variables already defined and ready to use. Be sure to check out Python Fire's documentation for more on this and the other useful features Fire provides.
Between Python Fire's simplicity, generality, and power, we hope you find it a useful library for your own projects.
By David Bieber, Software Engineer on Google Brain
Share on Google+ Share on Twitter Share on Facebook

Labels: open source release , Python , releases
  

Google Privacy Terms
2017-03-03 15:18:32 +08:00
回复了 zglloo 创建的主题 Android 好奇本届奥斯卡颁奖上面 安卓录屏的问题
Google cast
2017-02-28 21:43:50 +08:00
回复了 fqlion 创建的主题 程序员 优酷、腾讯、爱奇艺 VIP 视频免费解析原理
m3u8,流媒体
2017-02-27 18:08:07 +08:00
回复了 k332159915 创建的主题 Android 设备限制 apk 签名文件 只有指定的签名包才能安装!
lz 这标题一开始就把大家往瞎处带
2017-02-19 17:55:31 +08:00
回复了 haruhi 创建的主题 问与答 4K 显示器求推荐,可接受价位在 3K - 4K 之间
LG 那个 3 屏一排屁股的那个 https://www.youtube.com/shared?ci=WHY4rcX1WBQ
2017-02-15 14:28:43 +08:00
回复了 forex118899 创建的主题 Android 哪些国内手机可以刷 google 原厂 android ROM?
moto
2017-02-15 14:12:23 +08:00
回复了 holinhot 创建的主题 生活 女友说情人节想要个 macbook pro
那些结婚上交工资卡的是真宝强?
vlc
2017-02-15 13:46:32 +08:00
回复了 realpg 创建的主题 程序员 一个 5G WIFI 的奇葩问题 竞猜
手机不支持 5g
2015-04-16 20:56:02 +08:00
回复了 moonv5 创建的主题 分享发现 Google 手写输入 App 上架 Google Play
谷歌拼音输入法可以全屏手写,9宫格 全键盘 笔画和语音输入
你的不是Nexus手机吗?
2015-04-11 18:41:42 +08:00
回复了 devz1984 创建的主题 宽带症候群 运营商劫持我的网页访问放广告。 应该怎么办。
用铅笔!在太空中用铅笔!
2015-04-11 18:39:14 +08:00
回复了 wbsdty331 创建的主题 硬件 有没有什么好用的千元机?
moto g 2代
2015-03-23 20:54:28 +08:00
回复了 cruelcage 创建的主题 Android Nexus 5 跪了,好像是是硬件问题,有没有人跟我一样的?
lg大坑
2015-02-28 14:11:42 +08:00
回复了 thinkxen 创建的主题 汽车 今年准备换车,凌渡,求解毒。
孔大众
1  2  3  4  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3644 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 36ms · UTC 04:23 · PVG 12:23 · LAX 20:23 · JFK 23:23
Developed with CodeLauncher
♥ Do have faith in what you're doing.