typechecks: just say no! (was Re: Determining Types)
Alex
new_name at mit.edu
Mon Sep 3 11:12:06 EDT 2001
> In yet other places I want to iterate over the fields of a record, as
> in
>
> for key, value in rec:
>
> So in __getitem__ I check the type of index, returning getattr(self,
> index) if index is a string and saying
>
> fieldname=self.__fieldnames__[index]
> return (fieldname, getattr(self, fieldname))
>
> if index is an integer.
Iterators in python2.2 pretty much fix this problem.
Alex.
More information about the Python-list
mailing list