类方法定义的第一个参数必须为self,调用时这个参数会被传递为对象本身。类似于perl,perl中第一个参数也会被传递为对象本身,不过需要程序员自己写 my $self = shift; 来接收。
用C++的话来说,所有成员函数都是虚函数。
调用基类方法时要手工传递self,如 Parnet.__init__(self, name)。
模块
import foo; 相当于perl的 use foo;
from foo import bar 相当于perl的 use foo qw/bar/;
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn