On Aug 16, 12:50 am, Michele Simionato <[EMAIL PROTECTED]> wrote: > On Aug 16, 4:48 am, Nadeem <[EMAIL PROTECTED]> wrote: > > > I understand the 99% rule... the example I gave was to simplify the > > issue. The full thing I'm working on is a library for an introductory > > CS class I'm teaching. I'm trying, essentially, to build a library of > > macros for students to use allowing them to define records (like > > structs in C) with selector functions. > > The namedtuple recipe by Raymond Hetting does > exactly that and, guess what, it uses exec!
I might be wrong, but the reason namedtuple uses exec is performance. IIRC earlier versions of the recipe used a metaclass instead, so it's not that it *has* to use exec, it's just an optimization, totally justified in this case since namedtuples should be almost as fast as plain tuples. George -- http://mail.python.org/mailman/listinfo/python-list