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 mymodulewhere the code is located in filemymodule.py. Then saymymodule.fibto 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.