元句法主题的元句法变量名称
metasyntactic的Python项目详细描述
Version: | 0.99 |
---|
概要
这是优秀perl模块Acme::MetaSyntactic的一个端口, 作者:菲利普(书)布鲁哈特。
实际上,它是从acme::metasynctaic自动生成的。 这个特定的版本是从0.99版生成的。
原始贡献者文件随此发行版提供。
用法
一般
获取所有主题的列表:
>>> import metasyntactic >>> metasyntactic.all_themes set(...)
获取随机主题:
>>> metasyntactic.random() <module 'metasyntactic.themes.stars' from 'metasyntactic/themes/stars.py'>
从随机主题中获取随机元变量:
>>> metasyntactic.random().random() ['Barbouille']
从随机主题中获取4个随机元变量:
>>> metasyntactic.random().random(4) ['eve', 'irene', 'frank', 'ellen']
从4个随机主题中获取随机元变量:
>>> [theme.random() for theme in metasyntactic.random(4)] ['Barbouille', 'Fragarach', 'Grumpy', 'the_Lord_of_the_Rings']
从4个随机主题中获取2个随机元变量:
>>> [theme.random(2) for theme in metasyntactic.random(4)] [['Lupa', 'Civetta'], ['spigot', 'physique'], ['Patrice_Petit', 'Yvette_Chauvire'], ['GiNG_GiNG', 'DOINK_DOINK_DOINK_DOINK']]
主题
# Get theme by theme name >>> foo = metasyntactic.get(“foo”) >>> foo <module ‘metasyntactic.themes.foo’ from ‘metasyntactic/themes/foo.py’>
# Get random name >>> foo.random() ‘fubar’
# Get several random names. >>> foo.random(8) [‘bar’, ‘xyzzy’, ‘foobar’, ‘thud’, ‘foo’, ‘fred’, ‘garply’, ‘quux’]
# Get all names >>> foo.all() set(….)
类别
# Get random name in specific category >>> foo.random(8, category=”fr”) [‘truc’, ‘test1’, ‘machin’, ‘titi’, ‘tutu’, ‘pipo’, ‘test2’, ‘tata’]
# get default category >>> foo.default() ‘en’
# get all available categories >>> foo.categories() set([‘en’, ‘fr’, ‘nl’])
# get all names in specific category >>> foo.all(category=”fr”) set(…)
>>> yapc = metasyntactic.get("yapc")>>> yapc.random(4, section="america north") ['Buffalo', 'Pittsburgh', 'Boca_Raton', 'Saint_Louis']>>> yapc.sections() set(['america north', 'america south', 'asia', 'australia', 'brazil', 'canada', 'europe', 'israel', 'taipei'])
安装
您可以通过python包索引(pypi)安装metasyntactic。 或者来源。
使用pip,:
安装$ pip install metasyntactic
使用easy_install,:
安装$ easy_install metasyntactic
如果你下载了一个源tarball,你可以安装它 执行以下操作:
$ python setup.py build # python setup.py install # as root
错误跟踪程序
如果您有任何建议、错误报告或烦恼,请报告 我们的问题跟踪者在http://github.com/ask/metasyntactic/issues/
许可证
此软件是在Artistic License下授权的。 我不为这部作品保留任何版权 应该归功于原作者。