can modules be dynamically reloaded

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

    #1

    can modules be dynamically reloaded

    Can python modules be reloaded.

    For example you import a module, programatically edit it, then have the
    file reload the module?

    Does anyone have any ideas about this?
    Steve

  • Benjamin Niemann

    #2
    Re: can modules be dynamically reloaded

    Steve wrote:
    [color=blue]
    > Can python modules be reloaded.[/color]

    Yes:

    import mymod
    ....
    reload(mymod)

    But this will not always work as expected (what someone would expect who
    does not really understand how it works...). Read the documentation on
    <http://docs.python.org/lib/built-in-funcs.html#l2h-59>
    [color=blue]
    > For example you import a module, programatically edit it, then have the
    > file reload the module?
    >
    > Does anyone have any ideas about this?
    > Steve[/color]

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://www.odahoda.de/

    Comment

    • Benjamin Niemann

      #3
      Re: can modules be dynamically reloaded

      Steve wrote:
      [color=blue]
      > Can python modules be reloaded.[/color]

      Yes:

      import mymod
      ....
      reload(mymod)

      But this will not always work as expected (what someone would expect who
      does not really understand how it works...). Read the documentation on
      <http://docs.python.org/lib/built-in-funcs.html#l2h-59>
      [color=blue]
      > For example you import a module, programatically edit it, then have the
      > file reload the module?
      >
      > Does anyone have any ideas about this?
      > Steve[/color]

      --
      Benjamin Niemann
      Email: pink at odahoda dot de
      WWW: http://www.odahoda.de/

      Comment

      Working...