Issue
I'm trying to learn python and even though I now know the name of some methods, I still have to google their usage, since I never know if the method gives an output that I have to assign, or if it changes the input:
mylist = list()
givesnone = mylist.append("text") # why no list output?
print(givesnone)
mylist[0].replace("text", "replaced") # why not replacing?
print(mylist) # not replaced
mylist[0] = mylist[0].replace("text", "replaced")
print(mylist) # replaced
I want to be able to anticipate the behavior of methods without searching if I know their name, so how can I know if I have to assign the output or not?
Solution
You can use the help() method to view help information.
If you use an IDE to help you develop, for example, PyCharm. Then you can use the shortcut keys to jump to the method definition page, such as command + b on Mac.
Answered By - pppig Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.