diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py index c2d3963..a904793 100644 --- a/IPython/core/magics/osm.py +++ b/IPython/core/magics/osm.py @@ -808,17 +808,17 @@ class OSMagics(Magics): This magic command can either take a local filename, an url, an history range (see %history) or a macro as argument :: + If no parameter is given, prints out history of current session up to + this point. + %pycat myscript.py %pycat 7-27 %pycat myMacro %pycat http://www.example.com/myscript.py """ - if not parameter_s: - raise UsageError('Missing filename, URL, input history range, ' - 'or macro.') - - try : - cont = self.shell.find_user_code(parameter_s, skip_encoding_cookie=False) + try: + cont = self.shell.find_user_code(parameter_s, + skip_encoding_cookie=False) except (ValueError, IOError): print("Error: no such file, variable, URL, history range or macro") return