Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python class reflect method of member instance

url = input("input url:")  # Enter www.xxx.com/accout/fun to return the result of fun and 404 if it does not exist.
target_module, target_func = url.split('/')
# module = __import__('backend.'+target_module) #Using fromlist=True, you can import backend
module = __import__('backend.'+target_module, fromlist=True) #Using fromlist=True, you can import backend.accout.
func_name = url.split('/')[-1]
if hasattr(module, target_func): #Determine whether module contains target_func members
    target_func = getattr(module, target_func) #Get a reference to func_name
    target_func() #Execution function
Comment

PREVIOUS NEXT
Code Example
Python :: socialscan 
Python :: Express + Jade : Ensuring url paths are correct via controllers, orphaned links 
Python :: get command line variables python 
Python :: extracting code blocks from Markdown 
Python :: Python-Specific Operators 
Python :: Invenco Order Dict 
Python :: python request.args.get list 
Python :: import all csv as individual dataframes python 
Python :: ring Create Lists 
Python :: ring PostgreSQL load the postgresqllib.ring library 
Python :: negative max in python 
Python :: python sort dict by sub value 
Python :: create schema for table for django 
Python :: how to write stuff in python 
Python :: Problems with flask bootstrap 
Python :: how to download feature engine in spyder console 
Python :: how to add list toa key in ict 
Python :: dataframe from function 
Python :: gun in python turtle 
Python :: where are dictd dictionaries 
Python :: python how to dump exception stak 
Python :: jupyter notebook save as python script without terminal prompts line numbers 
Python :: 1007 solution python 
Python :: how to read json file from s3 bucket into aws glue job 
Python :: check internet speed using python 
Python :: python fork error 
Python :: tkinter auto refresh content periodically 
Python :: not all arguments converted during string formatting postgresql 
Python :: trigger to print on python 
Python :: How determine if a number is even or odd using Recursive Inner Function 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =