Re: OO question

2007-01-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > First I want to say thanks everyone for helping me! > > John Machin wrote: > > >>[EMAIL PROTECTED] wrote: >> >>>I want to make an addressbook and I'm new to OO programming, so I >>>wonder if this sounds reasonable. >>> >>>I think of making a class Address which cont

Re: OO question

2007-01-01 Thread Dan Sommers
On 1 Jan 2007 17:09:19 -0800, [EMAIL PROTECTED] wrote: > Lets say I have those two classes, Person and Address. How would one > implement the relationship between them? First, a Person can have one > or more addresses (or none), that could be represented as a list of > Addresses, right? But then,

Re: OO question

2007-01-01 Thread Paddy
Steven D'Aprano wrote: > On Sun, 31 Dec 2006 22:00:58 -0800, Paddy wrote: > > >> def save(self, filename): > >> self.currentfile = file(filename, "w") > >> for address in self.addresses: > >> self.save_one_address(address.export()) > >> self.currentfile.clos

Re: OO question

2007-01-01 Thread Tim Henderson
On Jan 1, 8:09 pm, [EMAIL PROTECTED] wrote: > Lets say I have those two classes, Person and Address. How would one > implement the relationship between them? First, a Person can have one > or more addresses (or none), that could be represented as a list of > Addresses, right? But then, if I have an

Re: OO question

2007-01-01 Thread fejkadress
First I want to say thanks everyone for helping me! John Machin wrote: > [EMAIL PROTECTED] wrote: > > I want to make an addressbook and I'm new to OO programming, so I > > wonder if this sounds reasonable. > > > > I think of making a class Address which contains all data about one > > person, tha

Re: OO question

2007-01-01 Thread robert
[EMAIL PROTECTED] wrote: > If I want to save all addresses to disk, I can have a method, say, > save() of AddressBook. But then what? What is a good object oriented > approach? Should each Address object take care of saving itself to the > file, with a method like writetofile(filename), or should t

Re: OO question

2007-01-01 Thread Steven D'Aprano
On Sun, 31 Dec 2006 22:00:58 -0800, Paddy wrote: >> def save(self, filename): >> self.currentfile = file(filename, "w") >> for address in self.addresses: >> self.save_one_address(address.export()) >> self.currentfile.close() >> self.currentfile = Non

Re: OO question

2007-01-01 Thread John Machin
[EMAIL PROTECTED] wrote: > I want to make an addressbook and I'm new to OO programming, so I > wonder if this sounds reasonable. > > I think of making a class Address which contains all data about one > person, that class can have UserDict as baseclass so I can access data > like object['name'], et

Re: OO question

2006-12-31 Thread Paddy
Steven D'Aprano wrote: > On Sun, 31 Dec 2006 19:47:12 -0800, fejkadress wrote: > > > I want to make an addressbook and I'm new to OO programming, so I > > wonder if this sounds reasonable. > > > > I think of making a class Address which contains all data about one > > person, that class can have

Re: OO question

2006-12-31 Thread Paddy
[EMAIL PROTECTED] wrote: > I want to make an addressbook and I'm new to OO programming, so I > wonder if this sounds reasonable. > > I think of making a class Address which contains all data about one > person, that class can have UserDict as baseclass so I can access data In Python 2.4 or 2.5 yo

Re: OO question

2006-12-31 Thread Steven D'Aprano
On Sun, 31 Dec 2006 19:47:12 -0800, fejkadress wrote: > I want to make an addressbook and I'm new to OO programming, so I > wonder if this sounds reasonable. > > I think of making a class Address which contains all data about one > person, that class can have UserDict as baseclass so I can access

OO question

2006-12-31 Thread fejkadress
I want to make an addressbook and I'm new to OO programming, so I wonder if this sounds reasonable. I think of making a class Address which contains all data about one person, that class can have UserDict as baseclass so I can access data like object['name'], etc.. Then maybe I can have a class Ad

Re: newbie OO question

2006-04-20 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, Jeremy Winters <[EMAIL PROTECTED]> wrote: from SegmentValue import * I remember in the old days a computing support guy saying he refused to help any users with FORTRAN questions unless they had an "IMPLICIT NONE" in every program block. The corresponding

Re: newbie OO question

2006-04-20 Thread Larry Bates
Jeremy Winters wrote: > class SegmentValue: > def > __init__(self,seg=[0,0,0,0,0,0],value=0,description=""): > self.segment=seg > self.value=value > self.description=description > > #that's my class! note the default of a 6 item list > for the seg pa

Re: newbie OO question

2006-04-20 Thread lukasz . ciesnik
Jeremy Winters napisal(a): > class SegmentValue: > def > __init__(self,seg=[0,0,0,0,0,0],value=0,description=""): > self.segment=seg > self.value=value > self.description=description > > #that's my class! note the default of a 6 item list > for the s

newbie OO question

2006-04-20 Thread Jeremy Winters
class SegmentValue: def __init__(self,seg=[0,0,0,0,0,0],value=0,description=""): self.segment=seg self.value=value self.description=description #that's my class! note the default of a 6 item list for the seg parameter... which is then bound(?