Namespaces/introspection: collecting sql strings for validation

Aahz aahz at pythoncraft.com
Mon Apr 23 19:38:18 EDT 2007


In article <1hwzkoo.118nt2f1htv72tN%aleax at mac.com>,
Alex Martelli <aleax at mac.com> wrote:
>Martin Drautzburg <Martin.Drautzburg at web.de> wrote:
>>
>> The problem is the first part: how can I lookup the callers module and
>> the classobjs defined in there? Or finding any constant strings in the
>> caller's module would also be just fine. Or is there a completely
>> different way to do such a thing?
>
>Don't do black magic in production code.
>
>For just hacking around, see sys._getframe -- it can give you a frame
>object from where you can introspect into your caller's globals -- and
>the inspect module of the standard Python library.
>
>But don't put such black magic in production.  The completely different
>way is: just don't.

Could you expand on that?  After all, that's exactly what we do to
implement a super() that works with classic classes -- and it's certainly
production code.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"...string iteration isn't about treating strings as sequences of strings, 
it's about treating strings as sequences of characters.  The fact that
characters are also strings is the reason we have problems, but characters 
are strings for other good reasons."  --Aahz



More information about the Python-list mailing list