polymorphic function question

Discussion in 'Python' started by joblack, Sep 21, 2010.

  1. joblack

    joblack Guest

    Let's say I've got a function with

    def doesSomething(A='bla'):
    ....

    and I try to call it with a non existent variable with

    doesSomething(DoesNotExist)

    What will happen? Will it throw an exception or will it take the
    defautl value?
     
    joblack, Sep 21, 2010
    #1
    1. Advertising

  2. Am Tue, 21 Sep 2010 11:35:14 -0700 (PDT)
    schrieb joblack <>:

    > Let's say I've got a function with
    >
    > def doesSomething(A='bla'):
    > ...
    >
    > and I try to call it with a non existent variable with
    >
    > doesSomething(DoesNotExist)
    >
    > What will happen? Will it throw an exception or will it take the
    > defautl value?


    The interpreter is omniscient, just ask him:

    Python 2.6.6 (r266:84292, Aug 29 2010, 12:36:23)
    [GCC 4.4.5 20100824 (prerelease)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.

    >>> def doesSomething(A='bla'):

    .... pass
    ....
    >>> doesSomething(DoesNotExist)

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'DoesNotExist' is not defined


    --
    Greg
     
    Gregor Horvath, Sep 21, 2010
    #2
    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. Manco

    can webmethods be polymorphic?

    Manco, Feb 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    325
    Lionel LASKE
    Feb 3, 2005
  2. Thomas Britton

    polymorphic behaviour from class constant

    Thomas Britton, May 1, 2004, in forum: Java
    Replies:
    1
    Views:
    335
    Chris Uppal
    May 2, 2004
  3. Khanh  Le

    polymorphic question

    Khanh Le, May 2, 2004, in forum: Java
    Replies:
    3
    Views:
    397
    Tim Van Wassenhove
    May 2, 2004
  4. -electric.com

    SOAP: Creating a polymorphic Data Type

    -electric.com, Feb 17, 2005, in forum: Java
    Replies:
    0
    Views:
    391
    -electric.com
    Feb 17, 2005
  5. Ben Pope

    Polymorphic Function Pointers

    Ben Pope, Feb 28, 2006, in forum: C++
    Replies:
    5
    Views:
    321
    Alf P. Steinbach
    Feb 28, 2006
Loading...

Share This Page