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
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):
>>
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
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