How to import a module so that the current globals are available to the module?

How to import a module so that the current globals are available to the module?

Post by Scott Davi » Sat, 11 Apr 2009 07:17:55



Nope. Think about it. Only the first import is anything but a dict
lookup.
Even if you know how you want that to work, suppose you use two
different modules in a single program, both of which define a
"builtin" named "somename". Does the first one win? Does the second?
Does the last that actually imported? There is a hack that can let
you change the builtins module, but you don't want to use it: you make
your programs harder to understand.
Accept that you may want a bit of boilerplate if you have a common
base, and start each use with something like:

from base_functions import bibble, babble, bobble, bome

--Scott David Daniels
XXXX@XXXXX.COM
 
 
 

1. Why 'import module' will not import module.py but the directory module?

2. [patch 1/8] Immediate Values - Global Modules List and Module Mutex


If I understand this code correctly, then changing immediate values
needs some exclusion to avoid patching live code. You leave this to the
user with some very unclear rules.

The result is a real mess that has nothing to do with the module mutex
and list. These patches need a lot more work 8(

1) The immediate types are just kind of silly. See per-cpu for how it
handles this already. DECLARE_IMMEDIATE(type, var) is probably enough.

2) immediate_if() needs an implementation before you introduce it. Your
assumption that it's always unlikely seems non-orthogonal.

3) immediate_set(), _immediate_set() and immediate_set_early()? No
thanks! AFAICT you really want an "init_immediate(var, val)". This
means "you can patch all the references now, they're not executing".
Later on we could possibly have a super-stop-machine version which
ensures noone's preempted and handles the concurrent case. Maybe.

4) With an "init" interface not a "set" interface, you don't need
locking. Simpler.

Hope that helps,
Rusty.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/

3. [patch 1/8] Immediate Values - Global Modules List and Module Mutex

4. [patch 01/10] Immediate values - Global modules list and module mutex

5. [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4

6. Global variables in modules---preserving values between module calls

7. [PATCH 1/4] Dynamic Debug: Introduce global fake module param module.ddebug - V4

8. Help with a standard module to get current module name

9. Obtaining System.Refelction.Module for the current module

10. Supply Mini-Com Coupler Modules ,Mini-com Coupler Modules,Panduit Mini-com Coupler Module,Panduit Minicom Modules,Panduit Mini-Com Module,Panduit Mini-com Fiber Optic Adapter Modules

11. Making module content available in parent module

12. Disconnection module,Connection module,LSA plus disconnection module