polymorphic function question

J

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?
 
G

Gregor Horvath

Am Tue, 21 Sep 2010 11:35:14 -0700 (PDT)
schrieb joblack said:
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.
.... pass
.... Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'DoesNotExist' is not defined
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,920
Members
47,462
Latest member
ChanaLipsc

Latest Threads

Top