polymorphic function question
Gregor Horvath
gh at gregor-horvath.com
Tue Sep 21 14:39:08 EDT 2010
Am Tue, 21 Sep 2010 11:35:14 -0700 (PDT)
schrieb joblack <tobias.koeck at gmail.com>:
> 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
More information about the Python-list
mailing list