Python Forum
Class-Aggregation and creating a list/dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Class-Aggregation and creating a list/dictionary
#1
Hello

I am creating three classes and I try to use aggregation/association between them for inheritance.
The first class has the info of the student (Student class), the second one has the subject info (Cousre class) and the grades of a students - Grdes class (used association between student and course class).
Now I try to use aggregation between the grades class and the course class.

The methods of the Course class are: subject, name and grade

Thus I want to creata a dictionary in the Grades class, which stores the name as key and the grades as values of the students.
How can I do this with aggregation. I though of creating a library in a class but not in any method and use this "Grades.dictionary" to call it.
It seems though, when I try to use the name of a student (using a Course-object) in the dictionary created I get this:

<bound method Course.get_student_name of <__main__.Course object at 0x00000279478578E0>>


So it returns this instead of the student's name thus I cannot use the dictionary.

Thank you in advance!
Yoriz write Oct-03-2021, 05:10 PM:
Please post all code, output and errors (in their entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
Class-Aggregation and creating a list/dictionary - by IoannisDem - Oct-03-2021, 05:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dictionary in a list bashage 2 567 Dec-27-2023, 04:04 PM
Last Post: deanhystad
  filtering a list of dictionary as per given criteria jss 5 698 Dec-23-2023, 08:47 AM
Last Post: Gribouillis
  Sort a list of dictionaries by the only dictionary key Calab 1 501 Oct-27-2023, 03:03 PM
Last Post: buran
  How to read module/class from list of strings? popular_dog 1 483 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  How to add list to dictionary? Kull_Khan 3 1,017 Apr-04-2023, 08:35 AM
Last Post: ClaytonMorrison
  check if element is in a list in a dictionary value ambrozote 4 1,991 May-11-2022, 06:05 PM
Last Post: deanhystad
  Dictionary from a list failed, help needed leoahum 7 1,977 Apr-28-2022, 06:59 AM
Last Post: buran
  how to assign items from a list to a dictionary CompleteNewb 3 1,594 Mar-19-2022, 01:25 AM
Last Post: deanhystad
  Python, how to manage multiple data in list or dictionary with calculations and FIFO Mikeardy 8 2,619 Dec-31-2021, 07:47 AM
Last Post: Mikeardy
  Python dictionary with values as list to CSV Sritej26 4 3,028 Mar-27-2021, 05:53 PM
Last Post: Sritej26

Forum Jump:

User Panel Messages

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