私がこれを書いているとき、私が実際にこの問題を経験していることは、ほとんど非現実的なことのように思えます。
オブジェクトのリストがあります。これらの各オブジェクトは、Individual
私が作成したクラスのインスタンスです。
したがって、社会通念はそれisinstance(myObj, Individual)
が戻るべきだと言いTrue
ます. しかし、そうではありませんでした。だから私は自分のプログラミングにバグがあると思って、type(myObj)
を出力しinstance
ましmyObj.__class__
たIndividual
。
>>> type(pop[0])
<type 'instance'>
>>> isinstance(pop[0], Individual) # with all the proper imports
False
>>> pop[0].__class__
Genetic.individual.Individual
私は困惑しています!何を与える?
編集:私の個人クラス
class Individual:
ID = count()
def __init__(self, chromosomes):
self.chromosomes = chromosomes[:] # managed as a list as order is used to identify chromosomal functions (i.e. chromosome i encodes functionality f)
self.id = self.ID.next()
# other methods