什么表示python脚本名_在Python中使用与脚本名相同的类名有什么区别?

纯粹从语言的角度来看,除了可能与导入类的人产生一些混淆之外,它不会有任何区别。在

如果将此模块用作robotframework测试套件中的库,那么robot将自动实例化与库文件同名的类。该类中的方法将作为该库中的关键字公开。在

robotframework用户指南有一个标题为Creating test library class or module的部分,上面写着(emphasis mine):Python classes are always inside a module. If the name of a class

implementing a library is the same as the name of the module, Robot

Framework allows dropping the class name when importing the library.

For example, class MyLib in MyLib.py file can be used as a library

with just name MyLib. This also works with submodules so that if, for

example, parent.MyLib module has class MyLib, importing it using just

parent.MyLib works. If the module name and class name are different,

libraries must be taken into use using both module and class names,

such as mymodule.MyLibrary or parent.submodule.MyLib.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值