下面的示例阐释了几种不同类型的对象表达式。
The following example illustrates several different types of object expressions.
若要避免创建新的命名类型所需的额外代码和开销,可以使用对象表达式。
You use object expressions when you want to avoid the extra code and overhead that is required to create a new, named type.
如果使用对象表达式来最小化程序中创建的类型数目,您可以减少代码行数,并防止出现不必要的类型增殖。
If you use object expressions to minimize the number of types created in a program, you can reduce the number of lines of code and prevent the unnecessary proliferation of types.
I just want to remind you, if I wanted to, for example, type in an expression like that, notice the syntactical form, it's an expression, a number, followed by an operand, followed by another expression.
我想要提醒下大家,如果你想要,例如,输入一个这样的表达式,注意语法形式,这是个表达式,一个数字,后面是一个运算对象,后面是另外一个表达式。
And in Python the expression is, operand, operator, operand, when we're doing simple expressions like this, and if I give it to the interpreter, it gives me back exactly what you'd expect, which is that value. OK?
在Python中表达式就是,运算对象,操作符,运算对象,当我们处理这样的简单表达式的时候,我把表达式传给处理器,处理器给我返回了我想要的结果,对不对?
So, operands. Let us take expressions, get values out, we can store them away in places, but ultimately we want to do something with them, so we need to now start talking about what are the things we can do inside of Python, or any programming language, to manipulate them.
也就是运算对象,让我们看看这些表达式,然后看看里面的这些值,我们可以把他们存在计算机的任何位置中,最终目的还是要对这些值做一些操作,因此我们现在需要开始讨论,在Python里面可以做什么,来操作它们了,或者在任何编程语言里。
应用推荐