Re: Overloading __init__ & Function overloading

Discussion in 'Python' started by Steve Holden, Sep 30, 2005.

  1. Steve Holden

    Steve Holden Guest

    Iyer, Prasad C wrote:
    > I am new to python.
    > I have few questions
    > a. Is there something like function overloading in python?


    Not in the same way as Java: you can't write several functions and have
    the compiler or run-rime system work out which one to call according to
    argument types. Don't forget that Python is so dynamic that the types of
    a function's arguments may vary between successive iterations of the
    same statement.

    > b. Can I overload __init__ method
    >

    The normal way to do this is to have the subclass's __init__ call the
    superclass's __init__, usually right at the start.

    When you get deeply into Python you will learn that you even call a
    function to determine the right superclass on which to call __init__.

    What is "super()"?

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC www.holdenweb.com
    PyCon TX 2006 www.python.org/pycon/
     
    Steve Holden, Sep 30, 2005
    #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. Steven Bethard
    Replies:
    2
    Views:
    458
    Steven Bethard
    Feb 16, 2005
  2. Iyer, Prasad C

    Overloading __init__ & Function overloading

    Iyer, Prasad C, Sep 30, 2005, in forum: Python
    Replies:
    3
    Views:
    6,414
    Fredrik Lundh
    Sep 30, 2005
  3. Fredrik Lundh
    Replies:
    0
    Views:
    451
    Fredrik Lundh
    Sep 30, 2005
  4. Iyer, Prasad C
    Replies:
    4
    Views:
    581
    John J. Lee
    Sep 30, 2005
  5. Fredrik Lundh
    Replies:
    0
    Views:
    403
    Fredrik Lundh
    Sep 30, 2005
Loading...

Share This Page