Am 29.10.2012 00:30, schrieb goldtech:
class Contact:
all_contacts = []
def __init__(self, name, email):
self.name = name
self.email = email
Contact.all_contacts.append(self)
Okay, a class that automatically registers all instances in a central list.
OK,
On Mon, Oct 29, 2012 at 10:30 AM, goldtech wrote:
> Hi,
>
> Trying to learn Python OOP. An example from a book, may not be
> formated after sending post but:
>
> class Contact:
> all_contacts = []
> def __init__(self, name, email):
> self.name = name
> self.email = email
>
On Sun, Oct 28, 2012 at 4:30 PM, goldtech wrote:
> Hi,
>
> Trying to learn Python OOP. An example from a book, may not be
> formated after sending post but:
>
> class Contact:
> all_contacts = []
> def __init__(self, name, email):
> self.name = name
> self.email = email
>
Hi,
Trying to learn Python OOP. An example from a book, may not be
formated after sending post but:
class Contact:
all_contacts = []
def __init__(self, name, email):
self.name = name
self.email = email
Contact.all_contacts.append(self)
OK, no I do this:
>>> c = C