X
X

Select Your Currency

Türk Lirası $ US Dollar
X
X

Select Your Currency

Türk Lirası $ US Dollar
Yıllık Satın Alımlarda %15 İndirim: Şimdi Tasarruf Edin! Detaylı Bilgi İçin Tıklayın!

Knowledge Base

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?
(50 times viewed. / 0 people found helpful.)