处理<代码>_repr__()功能的最好办法是什么? 例如,在数据库中代表一行(有关或物体)。
根据 Python,_repr__(
)。 应将该物体重新编号为eval(
),这样(大约)eval(repr(obj)= obj
,或打字表示无效。 通常,这意味着将物体可能重新生成的所有数据倾倒在扼杀中。 然而,对于重新计算物体的持久性物体,从数据库中检索数据可能简单。
因此,就这些物体而言,所有物体数据或仅仅是__repr__()
中的主要关键内容?
处理<代码>_repr__()功能的最好办法是什么? 例如,在数据库中代表一行(有关或物体)。
根据 Python,_repr__(
)。 应将该物体重新编号为eval(
),这样(大约)eval(repr(obj)= obj
,或打字表示无效。 通常,这意味着将物体可能重新生成的所有数据倾倒在扼杀中。 然而,对于重新计算物体的持久性物体,从数据库中检索数据可能简单。
因此,就这些物体而言,所有物体数据或仅仅是__repr__()
中的主要关键内容?
repr should return a string that would re-create the object with eval
这对简单的类型,如t或str或浮,是合法的做法,但不能用15+栏的多col银物体使用。
例如,如果我有一个代表价格的班子,则有理由订立<条码>_repr__。 说明其主要特征:数额和货币
def __repr__(self):
return %s %s %(self.amount,self.currency)
如何从数据库中获取信息通常不感兴趣。 将物体重新编号为<代码>SomeModel(field1, Field2, ......)。
Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...
I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...
Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...
Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...
I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...
Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...
Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...
I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...