Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OOP-self question
#1
Here is a part of a code i found online while i am trying to get familiar with oop:
class ContactList(list):
    def search(self, name):
        """Return all contacts that contain the search value
        in their name."""
        matching_contacts = []
        for contact in self:
            if name in contact.name:
                matching_contacts.append(contact)
return matching_contacts
can you explain me the for loop please(
Quote: for contact in self:
),how does it go?
Reply


Messages In This Thread
OOP-self question - by IoannisDem - Dec-17-2018, 12:34 PM
RE: OOP-self question - by Gribouillis - Dec-17-2018, 12:42 PM
RE: OOP-self question - by IoannisDem - Dec-17-2018, 12:46 PM
RE: OOP-self question - by Gribouillis - Dec-17-2018, 12:55 PM
RE: OOP-self question - by buran - Dec-17-2018, 01:17 PM
RE: OOP-self question - by wavic - Dec-17-2018, 01:55 PM

Forum Jump:

User Panel Messages

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