I'm new to Python and wondering if Python (or IPython) has an equivalent to the invisible() function in R. The invisible() function returns values, but doesn't display them if run interactively, instead it just makes them available for assignment. For example:
doStuff <- function(x) {
// blah blah
return(invisible(retValue))
}
z = doStuff(x) // z has the return value
doStuff(x) // retValue doesn't get displayed
There does not seem to be a proper function in Python that is the same as R's invisible() function. However, you can simply use a variable set to a boolean value and then use an if statement to check if the boolean is set to True then you return the output of the function. Below is a simple version of what the code could look like, you can make this more complex and improve it (if this does not help you then I suggest that you put some research into function outputs in python):
def function(INPUTS): # function code to get ouput return_value = False if return_value == True: return ouput
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.