X

Select Your Country

Turkey (Türkçe)Turkey (Türkçe) Worldwide (English)Worldwide (English)
X

Select Your Currency

Türk Lirası $ US Dollar

Using String as Dynamic Method Name in Python

Using String as Dynamic Method Name in Python
HomepageKnowledge BaseGeneralUsing String as Dynamic Method Name...
Using String as Dynamic Method Name in Python

We will use val to call automatic methods based on string in your application.

For example .

If you want to respond according to the incoming request and have it dynamically controlled, such as whether it starts or ends with a word, you can look at the example below.

standard = "call me?".startswith("call me")
print(standard)

func_ = 'startswith'
#func_ = 'endswith'
body_ = 'can you call me'
text_ = 'call me'

evalli = eval(f'"{body_}".{func_}("{text_}")')
print(evaluated)

You can click for our high-performance virtual servers.

Can't find the information you're looking for?

You have examined the knowledge base in detail, but if you cannot find the information you need,

Create a Support Ticket
Did you find it useful?
(457 times viewed. / 0 people found helpful.)