[英]Python equivalent of the double colon (::) operator in java
What is the double colon(::) operator in java also known as method reference operator in Java equivalent in python ??什么是 Java 中的双冒号 (::) 运算符,也称为 Python 中 Java 中等效的方法引用运算符?
Syntax:句法:
<Class name>::<method name>
Example: "/absfds/dclckd/dsf: { "reference": false, "type": "object", "value": { "functionName": "", "artifactPath": "", "branch": "develop", "buildType": "", "buildCommand": "", "repository": "", "storageClass": "STANDARD_IA", "handler": "package along with class name::method" }, "volatile": true
示例:
"/absfds/dclckd/dsf: { "reference": false, "type": "object", "value": { "functionName": "", "artifactPath": "", "branch": "develop", "buildType": "", "buildCommand": "", "repository": "", "storageClass": "STANDARD_IA", "handler": "package along with class name::method" }, "volatile": true
The handler is inside a .json file which is accessing java files.处理程序位于访问 java 文件的 .json 文件中。 How to write the handler when it is accessing python files.
访问python文件时如何编写处理程序。 Does it remain the same ?
它保持不变吗?
This is not a valid JSON file, at least not in this format.这不是有效的 JSON 文件,至少不是这种格式。
To get a reference to a method in Python, you just use its name but without ()
, eg.要在 Python 中获取对方法的引用,您只需使用其名称但不使用
()
,例如。
>>> import os
>>> os.getenv
<function getenv at 0x...>
>>> os.getenv('EDITOR')
'nvim'
>>> f = os.getenv
>>> f('EDITOR')
'nvim'
(ETA: it works the same way if os
was a class, or an instance of a class.) (ETA:如果
os
是一个类或一个类的实例,它的工作方式相同。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.