[Python-Dev] Choosing a best practice solution for Python/extension modules (original) (raw)
Daniel Stutzbach daniel at stutzbachenterprises.com
Sat Feb 21 00:40:08 CET 2009
- Previous message: [Python-Dev] Choosing a best practice solution for Python/extension modules
- Next message: [Python-Dev] Choosing a best practice solution for Python/extension modules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Feb 20, 2009 at 5:27 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
Brett Cannon wrote: > If you import pickle and call pickle.A() you will get -13 which is not > what you are after.
Ah, you may want to think about that a bit more. There's a reason globals are looked up when they're used rather than when their function is defined. Even in your own example, B isn't defined at all when you define A.
No, I'm afraid Brett is quite right. Globals are looked up when the function is executed, true, but they are looked up within the module that defined the function. Functions defined in _pypickle would only call the _pypickle version of functions.
-- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20090220/ebe4cfd8/attachment.htm>
- Previous message: [Python-Dev] Choosing a best practice solution for Python/extension modules
- Next message: [Python-Dev] Choosing a best practice solution for Python/extension modules
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]