Where can you find the list of all the methods supported by strings in python
Asked
Active
Viewed 100 times
0
-
2Related: [Finding what methods a Python object has](/q/34439/4518341) – wjandrea Feb 02 '22 at 05:15
-
What have you searched for, and what did you find? What have you tried, and how did it fail? – tripleee Feb 02 '22 at 05:17
-
Welcome to Stack Overflow. Please read [ask] and keep in mind that this is not a discussion forum and that you are expected to make some attempt to solve problems yourself before asking here. I can literally copy and paste `Where can you find the list of all the methods supported by strings in python?` [into a search engine](https://duckduckgo.com/?q=Where+can+you+find+the+list+of+all+the+methods+supported+by+strings+in+python%3F) and get useful results. If you have ever previously heard the word `documentation`, that is also extremely useful for Internet searches. – Karl Knechtel Feb 02 '22 at 05:38
2 Answers
-1
The easiest way to find all methods & attributes correspondent for objects/class:
print(dir(str))
print(dir(dict))
print(dir(list))
To only get method:
name = str
str_methods = list(filter(lambda x:callable(getattr(name, x)), dir(name)))
print(str_methods)
And to about thier functionality or defination:
Suppose, str has method called zfill. But what thats mean?
print(help(str.zfill))
Mazhar
- 638
- 3
- 8
-
`dir()` gets all attributes, not just methods. For a working solution, see [this answer](/a/34452/4518341). – wjandrea Feb 02 '22 at 05:17
-
Ofcourse but it will be easy to distinct from attribute & method while start to use. And it's more easier to find all method name locally rather than from a website using ```dir``` – Mazhar Feb 02 '22 at 05:20