Callable assertion?

Lulu of the Lotus-Eaters mertz at gnosis.cx
Sun Oct 5 15:17:45 EDT 2003


"Terry Reedy" <tjreedy at udel.edu> wrote previously:
|The acid test is to try calling it:
|try: param()
|except TypeError, msg: <do whatever>

This is usually a bad idea though.  Many, if not most, things you call
can either have side effects and/or consume non-trivial resources (time,
memory, especially).

For example, you don't want to change state by making a call if you know
you are not ready for that state change until something else happens.
But you may want to know whether 'param' is callable before you bother
with the setup code.

Yours, Lulu...

--
Keeping medicines from the bloodstreams of the sick; food from the bellies
of the hungry; books from the hands of the uneducated; technology from the
underdeveloped; and putting advocates of freedom in prisons.  Intellectual
property is to the 21st century what the slave trade was to the 16th.





More information about the Python-list mailing list