Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #111772 > unrolled thread

Dynamically call methods where method is known by address vs name

Started byMalcolm Greene <python@bdurham.com>
First post2016-07-22 16:04 -0400
Last post2016-07-22 16:04 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Dynamically call methods where method is known by address vs name Malcolm Greene <python@bdurham.com> - 2016-07-22 16:04 -0400

#111772 — Dynamically call methods where method is known by address vs name

FromMalcolm Greene <python@bdurham.com>
Date2016-07-22 16:04 -0400
SubjectDynamically call methods where method is known by address vs name
Message-ID<mailman.64.1469217870.22221.python-list@python.org>
I know I can do the following:
 
>>> s = 'lower'
>>> getattr(s, 'upper')()
'LOWER'
 
But how could I do the same if I had the method 'address' (better
name???) vs. method name?
 
>>> upper_method = s.upper
 
How do I combine this upper_method with string s to execute the method
and return 'LOWER'?
 
Thank you,
Malcolm
 
 

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web