Python Forum
I cannot display object lists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I cannot display object lists
#1


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()
Reply
#2
(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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thank you for your interest...
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 45,707 May-06-2023, 08:14 AM
Last Post: pramod08728
  Creating list of lists from generator object t4keheart 1 2,161 Nov-13-2020, 04:59 AM
Last Post: perfringo
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,173 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,312 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  sort lists of lists with multiple criteria: similar values need to be treated equal stillsen 2 3,190 Mar-20-2019, 08:01 PM
Last Post: stillsen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020