Assigning a value to single underscore _ in Python/IPython interpreter
问题 I created this function in Python 2.7 with ipython : def _(v): return v later if I call _(somevalue) , I get _ = somevalue . in[3]: _(3) out[3]: 3 in[4]: print _ out[4]: 3 The function has disappeared! If I call _(4) I get: TypeError: 'int' object is not callable` Why? What's wrong with this function? 回答1: The Python interpreter assigns the last expression value to _ . This behaviour is limited to the REPL interpreter only, and is intended to assist in interactive coding sessions: >>> import