classes for fun and newbies
Emile van Sebille
emile at fenx.com
Wed Mar 20 08:54:54 EST 2002
Bruce Dykes
<snip>
> class call_record:
> def __init__(self, record=''):
> self.record_id=record[0:5]
> self.date=record[6:11]
>
> etc...
>
> Now what I expect to be able to do is say:
>
> log = readlines(today.log)
>
> and then summon discrete bits of info like so:
>
> print call_record.record_id(log[1])
>
If all you want is the record_id you could do:
print call_record(log[1]).record_id
But if you want to get to the other attributes, you'll probably want to
save a reference to the object:
this_rec = call_record(log[1])
and then access the attributes:
this_rec.record_id
this_rec.date
etc.
HTH,
--
Emile van Sebille
emile at fenx.com
---------
More information about the Python-list
mailing list