module global variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pistacchio

    module global variables

    hi to all!
    can i load a module passing to it, automatically and as default, all
    the caller's global variables to act as module's global variables?
    thanks
  • alex23

    #2
    Re: module global variables

    On May 12, 5:17 pm, pistacchio <pistacc...@gma il.comwrote:
    hi to all!
    can i load a module passing to it, automatically and as default, all
    the caller's global variables to act as module's global variables?
    thanks
    module = __import__('mod ule', globals=globals ())

    I think that's what you're looking for.

    - alex23

    Comment

    • pistacchio

      #3
      Re: module global variables

      On 12 Mag, 10:01, alex23 <wuwe...@gmail. comwrote:
      On May 12, 5:17 pm, pistacchio <pistacc...@gma il.comwrote:
      >
      hi to all!
      can i load a module passing to it, automatically and as default, all
      the caller's global variables to act as module's global variables?
      thanks
      >
      module = __import__('mod ule', globals=globals ())
      >
      I think that's what you're looking for.
      >
      - alex23

      hmm, well, maybe yes.. should i ovveride the standard import function
      of the module?
      say that the module is called "pycatrix", would adding this to the
      module solve the problem?

      def __import__('pyc atrix', globals=globals ()):

      Comment

      • pistacchio

        #4
        Re: module global variables

        On 12 Mag, 10:10, pistacchio <pistacc...@gma il.comwrote:
        On 12 Mag, 10:01, alex23 <wuwe...@gmail. comwrote:
        >
        On May 12, 5:17 pm, pistacchio <pistacc...@gma il.comwrote:
        >
        hi to all!
        can i load a module passing to it, automatically and as default, all
        the caller's global variables to act as module's global variables?
        thanks
        >
        module = __import__('mod ule', globals=globals ())
        >
        I think that's what you're looking for.
        >
        - alex23
        >
        hmm, well, maybe yes.. should i ovveride the standard import function
        of the module?
        say that the module is called "pycatrix", would adding this to the
        module solve the problem?
        >
        def __import__('pyc atrix', globals=globals ()):
        pardon, this:
        def __import__('pyc atrix', globals=globals ()):
        pass

        Comment

        • Marco Mariani

          #5
          Re: module global variables

          pistacchio wrote:
          On 12 Mag, 10:01, alex23 <wuwe...@gmail. comwrote:
          >On May 12, 5:17 pm, pistacchio <pistacc...@gma il.comwrote:
          >>
          >>hi to all!
          >>can i load a module passing to it, automatically and as default, all
          >>the caller's global variables to act as module's global variables?
          Are you positively sure you need this?

          Modifying imported modules is already quite fragile, but this.. it's
          basically a reversed(import *)

          It's quite messy. Where quite equals to "very"

          Comment

          • pistacchio

            #6
            Re: module global variables

            On 12 Mag, 10:47, Marco Mariani <ma...@sferacar ta.comwrote:
            pistacchio wrote:
            On 12 Mag, 10:01, alex23 <wuwe...@gmail. comwrote:
            On May 12, 5:17 pm, pistacchio <pistacc...@gma il.comwrote:
            >
            >hi to all!
            >can i load a module passing to it, automatically and as default, all
            >the caller's global variables to act as module's global variables?
            >
            Are you positively sure you need this?
            >
            Modifying imported modules is already quite fragile, but this.. it's
            basically a reversed(import *)
            >
            It's quite messy. Where quite equals to "very"
            well, i'm writing a module called pycatrix. within the module i have
            compile / exec statements in a functions that work on global
            variables. ( exec compiledTemplat e in globals() ).

            now, i don't want to be forced (or force the end user) to import to
            call the module's function with a compulsory "globals()" as argument.

            Comment

            • pistacchio

              #7
              Re: module global variables

              On 12 Mag, 11:11, pistacchio <pistacc...@gma il.comwrote:
              On 12 Mag, 10:47, Marco Mariani <ma...@sferacar ta.comwrote:
              >
              pistacchiowrote :
              On 12 Mag, 10:01, alex23 <wuwe...@gmail. comwrote:
              >On May 12, 5:17 pm,pistacchio<p istacc...@gmail .comwrote:
              >
              >>hi to all!
              >>can i load a module passing to it, automatically and as default, all
              >>the caller's global variables to act as module's global variables?
              >
              Are you positively sure you need this?
              >
              Modifying imported modules is already quite fragile, but this.. it's
              basically a reversed(import *)
              >
              It's quite messy. Where quite equals to "very"
              >
              well, i'm writing a module called pycatrix. within the module i have
              compile / exec statements in a functions that work on global
              variables. ( exec compiledTemplat e in globals() ).
              >
              now, i don't want to be forced (or force the end user) to import to
              call the module's function with a compulsory "globals()" as argument.
              up

              Comment

              Working...