default argument values qns

Tim Chase python.list at tim.thechases.com
Thu Jun 1 09:53:21 EDT 2006


> i have declared a function like this:
> 
> def aFunction ( arg1 , arg2 = 0):
>          ....
>          print type(arg2)
> 
> when i try to print the type of arg2, it gives me 'str'
> type..why is it  not integer type, since i have declared
 > it as 0 ??


 >>> def a(arg1, arg2=0):
...     print type(arg2)
...
 >>> a("something")
<type 'int'>


Looks like it's an int to me.  You must be doing something 
spurious in your mysterious "...." that changes the data type.

-tkc






More information about the Python-list mailing list