为了让此类情景更易于读懂,也为了避免必须多次重用相同的方法名,在Python版本2.4中引入了方法修饰符。
To make situations like this more readable and to avoid having to reuse the same method name multiple times, method decorators were introduced in Python version 2.4.
标注作为修饰符,可以添加到包、类、接口、方法或字段声明中。
Annotations serve as modifiers that can be added to packages, classes, interfaces, methods, or field declarations.
可以看出,第一步是去掉private修饰符,用def替换它,这与将方法声明为public是一样的。
So as you can see, my first step would be to drop the private modifier and replace it with def, which is the same as declaring the method as public.
default这个特殊方法使用 @cherrypy.expose 修饰符标记为 CherryPy处理程序函数。
The special method default is marked as a CherryPy handler function by the @cherrypy.expose decorator.
注释是可以添加到代码中的修饰符,可以用于包声明、类型声明、构造函数、方法、字段、参数和变量。
Annotations are modifiers you can add to your code and apply to package declarations, type declarations, constructors, methods, fields, parameters, and variables.
修饰符的一种常见用法是注释静态方法。
但是,我在创建修饰符时可以不用添加额外的基于类的方法结构。
But I can make a decorator without adding the extra structure of a class-based approach.
修饰符是一些方法,这些方法可以修改其他方法并返回一个方法或另外一个可调用对象。
Decorators are methods that modify other methods and return either a method or another callable object.
如果您需要在方法上设置sealed修饰符,那么选择(启用)方法的leaf属性。
If you need to set the sealed modifier on the method, select (enable) the Leaf property of the operation.
示例中的切入点使用了修饰符(modifier)和通配符(wildcard)模式来表达“所有公共方法”。
The pointcut in the example uses a modifier and wildcard pattern to express "all public methods."
使用此修饰符调用的任何方法都将只使用小写字符串。
Any method called with this decorator USES only lowercase strings.
如果方法的前缀使用 @abstractmethod修饰符(decorator),那么此方法就是一个抽象方法。
A method is abstract if it's preceded with the decorator @abstractmethod.
定义修饰符与定义其他方法无异。
方法的返回类型、修饰符可以相同,也可不同。
Of the method it is OK to return type, got-up accord with identical, also can differ.
运行时将允许在方法重载、隐藏及绑定中使用这些修饰符,但不会强制任何语言特定的语义。
The runtime will honor these modifiers for method overloading and hiding as well as for binding, but will not enforce any language-specific semantics.
返回具有指定名称、绑定信息、调用约定、参数类型和修饰符的方法。
Returns a method having the specified name, binding information, calling convention, and parameter types and modifiers.
为什么不能指定接口中方法的修饰符?
Why can't you specify the accessibility modifier for methods inside the interface?
Modifier类提供了静态方法和常量来对类和成员访问修饰符进行编码。
The Modifier class provides static methods and constants to decode class and member access modifiers.
继承修饰符控制派生类的方法和属性如何重写基类中的方法和属性。
Inheritance modifiers control how methods and properties from derived classes override methods and properties in a base class.
抽象类中可以有方法的实现,也可以指定方法的访问修饰符。
Overloading simply involves having a method with the same name within the class.
派生类中的方法重写基类方法,而且这两种方法的可见性修饰符是不同的。
A method in a derived class overrides a base-class method, and the visibility modifiers of the two methods are different.
抽象类中可以有方法的实现,也可以指定方法的访问修饰符。
When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.
对派生类方法的可见性修饰符进行修改,使其与基类方法的可见性相匹配。
Change the visibility modifier of the derived-class method to match the visibility of the base class method.
对派生类方法的可见性修饰符进行修改,使其与基类方法的可见性相匹配。
Change the visibility modifier of the derived-class method to match the visibility of the base class method.
应用推荐