Thus far, for us it's been testing individual functions. Later in the term we'll talk about unit testing of classes.
至今为止,我们用到单元测试的地方,就是测试每个单独的方法,在后面我们会讲到类的单元测试。
It's got this funky looking form, right, it says, I've got something that I'm going to call a class, got that key word class right here.
以及我们怎么来使用这些方法,因此我要回到类这个概念上来,让我们来建立第一个类吧,就在你们课堂手册的这儿,我会去定义一个类。
Well, one way you can get it is by mixing the gene with lipids, with lipid molecules.
一种方法可以将基因与脂质体混合,同脂类分子混合
This is the kind of thing you should be able to deduce.
你们必须掌握推导这类问题的方法
We have historically developed regulations that deal with these problems.
有关机构已经制定了,处理这类问题的监管方法
When I try and evaluate that expression of greater than, is going to go into the class to say greater than is a comp method.
这个大于的操作符的时候,是到类的定义里去识别,大于是一个比较的方法,那么让我在这里说仔细一点吧。
Notice the form of it, it's just the name of the class followed by open paren, close paren, treating it like a function.
我该怎么来使用类呢?,好,我可以像调用方法,一样调用类,你可以在下面看到,创建一个名为。
Some of which I built: cmp, init, str. And there, notice, are the internal definitions And in fact I should've said, we often call those things fields.
就是给我一个所有东西的列表:,所有的方法,与这个类关联的,有一些是我写的:,还有这里,请注意,是一些内部的定义。
They are instances of a class, and associated with that class is a set of methods.
它们是同一个类的实例,与这个类相关联的是一个方法集,因此例如,我可以说。
So you can actually say, how do I know which methods are associated with the class? For that, we can call dir. And what it does, is it gives me back a listing of all the things, dir all the methods, that are associated with it.
我们开始建立类了,我们得到了这些方法,因此实际上你可以说,我怎么知道,哪些方法是关联与这些类的?,为了解决这个问题,我们可以调用,这个方法的作用。
These are instances of a class, and associated with that class are a set of methods things that I can deal with.
但是Python的基本思想是相同的,这是一些一个类的实例,这个类关联了一个方法集,我可以做的一些操作。
x and get the values of x and y attached to this thing and return them to me.
和y值然后把它们返回给我,It’s,going,to,go,off,这就是我想要的东西,我想要我的类里面有一些方法。
A newer version of this that works in a similar way but a different way is called RNA interference, and it turns out that this is a natural mechanism that cells have.
NA干扰是这类方法的新秀,它的原理与其大同小异,已经证实 这是细胞的自然机制
应用推荐