exec-function in Python 3.+

Discussion in 'Python' started by Hans Larsen, Nov 2, 2009.

  1. Hans Larsen

    Hans Larsen Guest

    Help!
    I'm begginer in Python 3.+!
    If i wih to update a module after an import and chages,
    How could I do:
    By "from imp import reload" and then reload(mymodule)
    or how to use "exec(?)", it is mentoined in docs.
    In Python ver. <3 reload(module) writes something back to interpretter!,
    how about exec, which is a function?-:)
    I,m thanking on the help!!
     
    Hans Larsen, Nov 2, 2009
    #1
    1. Advertising

  2. Hans Larsen

    Jon Clements Guest

    On 2 Nov, 10:49, "Hans Larsen" <> wrote:
    > Help!
    >     I'm begginer in Python 3.+!
    >     If i wih to update a module after an import and chages,
    >     How could I do:
    >     By "from imp import reload" and then reload(mymodule)
    >     or how to use "exec(?)", it is mentoined in docs.
    >     In Python ver. <3 reload(module) writes something back to interpretter!,
    > how about exec, which is a function?-:)
    >     I,m thanking on the help!!


    What makes you think you need to 'reload' a module. If you don't know
    exactly what you're doing (by saying you're a beginner I'm guessing
    not...), and aware of the consequences that can follow... I would say,
    *don't*. There's too much to bite you in the rear (and not a blatant
    bite from a lion, but rather a playful little kitten that then plays
    cute and exudes a "moi?" expression).

    Also, it may help others to post their thoughts if you tried to
    describe why you think you want to go down this line, and what you're
    trying to achieve.

    Jon.
     
    Jon Clements, Nov 2, 2009
    #2
    1. Advertising

  3. Hans Larsen

    Dave Angel Guest

    Hans Larsen wrote:
    > Help!
    > I'm begginer in Python 3.+!
    > If i wih to update a module after an import and chages,
    > How could I do:
    > By "from imp import reload" and then reload(mymodule)
    > or how to use "exec(?)", it is mentoined in docs.
    > In Python ver. <3 reload(module) writes something back to interpretter!,
    > how about exec, which is a function?-:)
    > I,m thanking on the help!!
    >
    >
    >

    I've never used reload() in 2.x or 3.x. If I'm debugging interactively
    with the command line interpreter and I get to this point, I exit() and
    start the python interpreter again. And if there was too much typing to
    waste by doing that, I write the code into another script, and run that
    from an IDE. From most IDE's, you get a fresh chance every time you
    start a run.

    I haven't found any reason to change this behavior. So if you have a
    use-case, please elaborate. And know that there are lots of traps in
    reloading a module, as it can't really eliminate all traces of being
    already run once. It works for simple stuff, but you don't need it for
    simple stuff,... And I guess I'm repeating myself.

    DaveA
     
    Dave Angel, Nov 2, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hal Vaughan
    Replies:
    11
    Views:
    1,195
    Gordon Beaton
    May 22, 2006
  2. tedsuzman
    Replies:
    2
    Views:
    7,163
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  3. Ted
    Replies:
    1
    Views:
    494
    Duncan Booth
    Jul 22, 2004
  4. Guillermo Riojas
    Replies:
    0
    Views:
    198
    Guillermo Riojas
    Nov 26, 2010
  5. Random Task
    Replies:
    12
    Views:
    724
    Joe Smith
    Dec 4, 2005
Loading...

Share This Page