這篇文章是我以前的文章(在Python中創建和檢索對象列表)的後續。在Python中創建和檢索對象列表增強
我不得不修改我的代碼以下列方式:
SCRIPT1
#!/usr/bin/python
class Porsche:
""" class representing a Porsche """
def __init__(self, color):
self.color = color
def create_porsche(parameter_1, parameter_2):
myPorsche = Porsche(color = parameter_1)
myPorsche2 = Porsche(color = parameter_2)
create_porsche(parameter_1 = 'blue', parameter_2 = 'red')
porsche_container = (myPorsche, myPorsche2)
,我想有porsche_container =(myPorsche,myPorsche2)工作方式一樣在我以前的腳本:
舊腳本1
#!/usr/bin/python
class Porsche:
""" class representing a Porsche """
def __init__(self, color):
self.color = color
myPorsche = Porsche(color = 'blue')
myPorsche2 = Porsche(color = 'red')
porsche_container = (myPorsche, myPorsche2)
我如何能做到這一點,請?
RGDS,
布魯諾嗨,它是什麼,你想實現/你是如何計劃使用呢?它可能會更容易幫助您獲得更多信息。 – MattH 2010-08-25 12:56:55
@MattH感謝您的關注,幸運的是Stack Overflow存在! – Bruno 2010-08-25 13:05:24