似乎python确实有名称空间.但我能得到的是人们告诉我什么名称空间或范围.那么如何在python中定义命名空间?我只需要语法(并举例说明会更好).
假设有一个这样的方法:someAPI(Integer)。我还有课
class MyClass{
int toInteger(){
0 // just for demo. the value will be generated on the fly
}
public <T> T asType(Class<T> c){
0 // just for demo. the value will be generated on the fly
}
}
MyClass myClass
someAPI(myClass as Integer) // OK but it's more like groovy than DSL
someAPI(myClass) // This is what i want, but it gives me an error: method not found.
Run Code Online (Sandbox Code Playgroud)
我怎样才能让groovy自动为我投射它?当然someAPI()不是我可以修改的。