How to create cross between __getattr__() and __getitem__()?

Doug Hellmann doughellmann at home.com
Wed Dec 8 07:22:42 EST 1999


John Lull wrote:
> 
> I need to have both of these work with a single invocation of
> queryRemoteDatabase():
> 
>   print a.dog
>   print a.cat[4]
> 
> in a system where class A cannot know ahead of time which is an
> integer and which is a tuple.

Why not make the call, store the return value, and test the type once
you have the value?

Doug



More information about the Python-list mailing list