Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pyyml

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyyml

Use python in yaml

  • 0.0.2
  • PyPI
  • Socket score

Maintainers
1

pyyml

Use python in yaml

基本使用

在python中使用:

from pyyml import load

with open('conf.yml') as f:
    raw_conf = f.read()
config = load(raw_conf)
print(config)

在yaml中 ${...} 中的内容将会被python执行:

yaml内容

sum: ${1 + 1}

实际解析内容

{'sum': 2}

通过在文件开头第一行注释来导入所需的包:

# libs:['os', 'os.path:path', 'this']

通过 [包名]:[别名] 取别名导入包

'os.path:path' 等同于 python 中的 from os import path

例如yaml文件内容

# libs:['os', 'os.path:path', 'this']
os_name: ${os.name}
base_dir: ${path.abspath(path.dirname(__file__))}

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc