Python Forum

Full Version: I cannot display object lists
You're currently viewing a stripped down version of our content. View the full version with proper formatting.


when I try to view the staff list.

eror:<<<<<< <__main__.Çalışan object at 0x0000000002D92550> <<<<<<



def personele_ekle():
    isim = raw_input()
    yeniobj = Çalışan(isim)

    Çalışan.personel.append(yeniobj)
    print
    yeniobj.isim
    print('{} adlı kişi personele eklendi'.format(yeniobj.isim))




class Çalışan():
    personel = []

    def __init__(self, isim):
        self.isim = isim
        self.kabiliyetleri = []


    @classmethod
    def personel_sayısını_görüntüle(cls):
        print(len(cls.personel))




    @classmethod
    def personeli_görüntüle(cls):
        print('Personel listesi:')
        for kişi in cls.personel:
            print(kişi)

    def kabiliyet_ekle(self, kabiliyet):
        self.kabiliyetleri.append(kabiliyet)

    def kabiliyetleri_görüntüle(self):
        print('{} adlı kişinin kabiliyetleri:'.format(self.isim))
        for kabiliyet in self.kabiliyetleri:
            print(kabiliyet)


def personele_ekle():
    isim = raw_input()
    yeniobj = Çalışan(isim)

    Çalışan.personel.append(yeniobj)
    print
    yeniobj.isim
    print('{} adlı kişi personele eklendi'.format(yeniobj.isim))



personele_ekle()

Çalışan.personel_sayısını_görüntüle()
Çalışan.personeli_görüntüle()
(May-07-2019, 08:13 AM)Karaca Wrote: [ -> ]eror:<<<<<< <__main__.Çalışan object at 0x0000000002D92550> <<<<<<
That's not an error. That is general representation of instance of your class. You need to implement __str__() method for your class if you want "nice" print. There is also __repr__ method (it's a bit different). Here you can read more https://docs.python.org/3/reference/data...ct.__str__

by the way, I am confused by Turkish language, but I don't see where you print the instance itself. I see you printing just some attributes of the instance. so this output is not result of exactly this code.
Thank you for your interest...