Thursday, 8 August 2013

IPython function call behavior

IPython function call behavior

I have a function in a script problem1.py:
def normal_method(target):
natural_numbers = np.array(np.arange(1,target))
divisible_numbers = np.array([x for x in natural_numbers
if x%3==0 or x%5==0])
sum_value = np.sum(divisible_numbers)
print sum_value
While calling this function in an IPython window using ,
from problem1 import normal_method
%timeit normal_method(100)
It gives me TypeError saying normal_method takes no arguments. But when I
paste the function into IPython and then call it using the same statement
it works. Any ideas why this occurs?

No comments:

Post a Comment