PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 16, 2022

[FIXED] How to anticipate in python if methods give outputs or change the object?

 August 16, 2022     methods, output, python, variable-assignment     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing