Python - how to make dynamic method

72 views Asked by At

I wonder how i can assign dynamic method (for example ".text" or ".split()") to my variable.

some_selector = "div.test"      # is it possible to add here a method? For example ".text"
soup.select_one(some_selector).text   # It would work, i want to achieve this, but in line above ( i don't want to have .text in this line).

Ideal solution (but it's not working):

some_selector = "div.test".text  # i added at the end of the sentence method
soup.select_one(some_selector)
0

There are 0 answers