title: Use variable passed to a function to call a member from a class in python
body: <pre><code>import nmap3
  
  def nmap_scan(address,nmapType):
      nmap = nmap3.Nmap()
      result = f'nmap.{nmapType}({address})'
      #result = nmap.nmapType(address) gives the error nmap type is not a member of class nmap
      print(result)
  
  nmap_scan(127.0.0.1,scan_top_ports) #user input will be given here
  </code></pre>
  <p>What I want the code to do is take user input on the type of scan he wants from the <code>python-nmap3</code> repo and use it as a variable in the <code>result = f'nmap.nmapType(address)'</code> line.</p>
  <p>However, if I remove the f string, <code>python</code> treats <code>nmapType</code> variable as a method to the class <code>nmap</code>. What I want is the user to be able to specify the method name in the variable <code>nmapType</code>.</p>
  <p>Is there a way around to solve this problem and use user input to call the correct <code>nmap</code> method based on user input?</p>
  <p>I want the user to enter the scan type, pass that to <code>nmap_scan</code> function, and use it to perform the scan.</p>