Obtaining an member function by name

EuGeNe eugene at boardkulture.com
Sat Nov 19 10:42:21 EST 2005


guy lateur wrote:
> Hi all,
> 
> Suppose you have this class:
> 
> class foo:
>     def bar():
> 
> Suppose you also have the strings "foo" and "bar". How can you obtain the 
> function foo.bar()?
> 
> Surely somebody knows..
> 
> TIA,
> g
> 
> 


Would that do?

 >>> class foo:
	@staticmethod
	def bar():
		pass

	
 >>> foo.bar
<function bar at 0x00B445F0>
 >>>



More information about the Python-list mailing list