Newbie Question

Discussion in 'Python' started by ishtar2020, Aug 28, 2006.

  1. ishtar2020

    ishtar2020 Guest

    Hi everyone

    I'm sure this question is kinda stupid and has been answered a few
    times before... but I need your help!

    I'm writing a small application where the user can analyze some text
    based on a set of changing conditions , and right now I'm stuck on a
    point where I'd like to automatically generate new classes that operate
    based on those user-defined conditions.

    Is there a way in python to define a class in runtime? For instance,
    can I define a class which extends another(that I have previously
    defined in some module) , create some instance completely on the fly
    and then add/redefine methods to it?

    If affirmative, I've thought of a problem I would maybe have to face:
    as the class has been defined by direct input to the python
    interpreter, I could only create instances of it on the same session I
    entered the definition(because it's not on a module I can load on
    future uses) but not afterwards. Is there a way to keep that code?

    Even more newbie paranoia: what would happen if I make that 'on the
    fly" object persist via pickle? Where would Python find the code to
    handle it once unpickled on another session (once again, i take that no
    code with the definition of that instance would exist, as it was never
    stored on a module).

    Hope it wasn't too ridiculous an idea.

    Thank you for your time, guys.
     
    ishtar2020, Aug 28, 2006
    #1
    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. Jerry C.
    Replies:
    8
    Views:
    256
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    149
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    130
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    117
  5. Miki Tebeka
    Replies:
    0
    Views:
    88
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page