python - How can I return raw_input to use under a different name? -
i'm trying create get_input() function can choose how input retrieved.
def get_input(input_msg = '', getparam = 0, style = 'raw'): if style.lower() 'arcpy': return arcpy.getparameterastext(getparam) if style.lower() 'raw': return raw_input(input_msg) however when used method got none no matter input parameter was. think because method imported main program doesn't have access parameters.
then tried
def get_input(style = 'raw'): if style.lower() 'arcpy': return arcpy.getparameterastext if style.lower() 'raw': return raw_input wanting return function use elsewhere , simplify inputs function, got error
typeerror: 'nonetype' object not callable for both settings of method. get_input() seems can return nonetype object in configuration.
how can fix able call raw_input() or arcpy.getparameterastext under different name?
the problem in if statements. is should never used comparison. editing code
def get_input(style = 'raw'): if style.lower() == 'raw': return raw_input if style.lower() == 'arcpy': return arcpy.getparameterastext raise ioerror("invalid input in 'style': {}".format(style)) fixed problem.
Comments
Post a Comment