Re: [Tutor] Dynamic Function Assignment

2005-10-21 Thread Alan Gauld
for id in ('A', 'B', 'C'): if segment.upper().startswith(id): Think dictionary: objects = {'A': a, 'B':b, 'C':c} for id in ('A','B','C') objects[id].method() I have a section within my OOP topic that specifically talks about this in the context of a collection of bank account objects. Y

Re: [Tutor] Dynamic Function Assignment

2005-10-20 Thread Kent Johnson
John Fouhy wrote: > On 21/10/05, Greg Lindstrom <[EMAIL PROTECTED]> wrote: > >> Suppose I have three objects... >> >> a = MyObject(id=1) >> b = MyObject(id=2) >> c = MyObject(id=3) >> >> segment = 'A Segment to Process' >> >> for id in ('A', 'B', 'C'): >>if segment.upper().startswith(id): >>

Re: [Tutor] Dynamic Function Assignment

2005-10-20 Thread John Fouhy
On 21/10/05, Greg Lindstrom <[EMAIL PROTECTED]> wrote: > Suppose I have three objects... > > a = MyObject(id=1) > b = MyObject(id=2) > c = MyObject(id=3) > > segment = 'A Segment to Process' > > for id in ('A', 'B', 'C'): > if segment.upper().startswith(id): >??how can I select th

[Tutor] Dynamic Function Assignment

2005-10-20 Thread Greg Lindstrom
Hello- Suppose I have three objects... a = MyObject(id=1) b = MyObject(id=2) c = MyObject(id=3) As I read in segments from my file, I need to choose one of the above based on the segment, something like this; segment = 'A Segment to Process' for id, S in (('A',a), ('B',b), ('C',c)):   if segme