Reputation: 846
My code is:
import os
#This function renames the given file!
def rename(file_name, new_name):
file_name = str(file_name)
a = os.rename(file_name, new_name)
return a
Now When I run my code in IDLE:
>>> help(rename)
Help on function rename in module __main__:
rename(file_name, new_name)
#This function renames the given file!
>>>
It returns like this!
If Code Like this:
import os
#This function renames the given file!
def rename(file_name, new_name):
#In the file_name you have to give the file's name with extention!
#In the new_name you have to give the new file's name with extention!
file_name = str(file_name)
a = os.rename(file_name, new_name)
return a
And use help function in IDLE:
>>> help(rename)
Help on function rename in module __main__:
rename(file_name, new_name)
#This function renames the given file!
>>>
It returns the same!
Is there and way to print all the comments
when i use:
>>>help(rename)
Help on function rename in module __main__:
rename(file_name, new_name)
#This function renames the given file!
#In the file_name you have to give the file's name with extention!
#In the new_name you have to give the new file's name with extention!
Like this?
Upvotes: 2
Views: 605
Reputation: 36
You have to use docstrings. for example:
def rename(file_name, new_name):
'''
In the file_name you have to give the file's name with extention!
In the new_name you have to give the new file's name with extention!
'''
file_name = str(file_name)
a = os.rename(file_name, new_name)
return a
so when you call help(rename), you should get:
Help on function rename in module __main__:
rename(file_name, new_name)
In the file_name you have to give the file's name with extention!
In the new_name you have to give the new file's name with extention!
Upvotes: 1
Reputation: 61
What you need is a docstring. You use """ """ format to give your function a documentation that can be viewed with the help function.
Upvotes: 0