include udf in python?
i've a small user defined function in python, say fib(n), how do i use that in other programs or modules?
def fib(n):
should i use import or is there any other feature?
Also i'm learning python in eclipse IDE, it wont support
print "any string"
but i开发者_运维知识库'm forced to use like,
print("string")
in python manual online, its given its cross platform and same syntax, but why like above?
You use import to include the function in other programs. Just say import mymodule
where the code is located in file mymodule.py
. Then say mymodule.fib
to use the function.
To answer your second question: The syntax print "any string"
is acceptable in Python 2, but is no longer allowed in Python 3.
精彩评论