``Type-checking'' with dir()

Asun Friere afriere at yahoo.co.uk
Mon Aug 18 00:50:57 EDT 2003


harry.pehkonen at hotpop.com (Harry Pehkonen) wrote in message news:<70df36e9.0308161136.3c414a80 at posting.google.com>...
> In order to leave my classes open to receiving objects that are
> string-like, list-like, dictionary-like, etc, and not necessarily
> _exactly_ the built-in string, list, dictionary, etc types, I have the
> desire to just check if the necessary methods exist. 


Why do you have this desire?  If your program is usually going to be
passed lists etc, isn't that a lot of expensive LBYL checking to have
to go through?  Is there some reason that simply handling the Type or
Attribute (or Whatever) errors won't suffice?




More information about the Python-list mailing list