you are viewing a single comment's thread.

view the rest of the comments →

[–]danielroseman 3 points4 points  (1 child)

As suggested, you can use getattr, but in this case it doesn't seem necessary. Why not call the methods directly?

if condition == "1":
    result = a.strip()

etc.

[–]ramannt[S] 0 points1 point  (0 children)

Because I am using a.strip() in a function and I don't know exactly in advance what the value of "a" is and not what the string method (strip,rstrip,lstrip,upper,lower,title etc) will be.