Finding name for a signal number

Oliver Fromme olli at
Tue Nov 6 15:14:13 CET 2001

Michael Hudson <mwh at> wrote:
 > Oliver Fromme <olli at> writes:
 > [...]
 > > This works.  However, the above code seems awkward and
 > > inefficient, in particular the eval() part.  Is there a
 > > better way?  Did I miss something?
 > Yes: getattr.

Ah!  Stupid me.  I've read about getattr before, I should
have remembered it.  Thanks for pointing me in the right
direction (thanks to Skip, too).

 > Also your logic seems a touch backwards - why search through the
 > module every time?

Well, I'd need it only once, cause I handle it as a fatal
error when a os.system() command is aborted by a signal.

You're right, of course -- if I needed to do the look-up
multiple times, the best thing is to build a dictionary.


Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

More information about the Python-list mailing list