diff options
| author | robot-piglet <[email protected]> | 2024-06-15 14:18:22 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2024-06-15 14:27:16 +0300 |
| commit | b52a8ab5cd66952839ada0843539b5564108a052 (patch) | |
| tree | 659c3387aee1dbb2629b3afd68f8d306d37b45c2 /contrib/python/ipython/py3/IPython/core/magics | |
| parent | 7d673060f61f85b3e440fa45df26795d3653c8d2 (diff) | |
Intermediate changes
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/magics')
4 files changed, 20 insertions, 20 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/magics/code.py b/contrib/python/ipython/py3/IPython/core/magics/code.py index 65ba52b8bbf..4f1574dcefd 100644 --- a/contrib/python/ipython/py3/IPython/core/magics/code.py +++ b/contrib/python/ipython/py3/IPython/core/magics/code.py @@ -452,7 +452,7 @@ class CodeMagics(Magics): # Load the parameter given as a variable. If not a string, # process it as an object instead (below) - #print '*** args',args,'type',type(args) # dbg + # print('*** args',args,'type',type(args)) # dbg data = eval(args, shell.user_ns) if not isinstance(data, str): raise DataIsObject @@ -636,8 +636,8 @@ class CodeMagics(Magics): In [1]: edit Editing... done. Executing edited code... - Out[1]: 'def foo():\\n print "foo() was defined in an editing - session"\\n' + Out[1]: 'def foo():\\n print("foo() was defined in an editing + session")\\n' We can then call the function foo():: @@ -661,21 +661,21 @@ class CodeMagics(Magics): In [5]: edit Editing... done. Executing edited code... hello - Out[5]: "print 'hello'\\n" + Out[5]: "print('hello')\\n" Now we call it again with the previous output (stored in _):: In [6]: edit _ Editing... done. Executing edited code... hello world - Out[6]: "print 'hello world'\\n" + Out[6]: "print('hello world')\\n" Now we call it with the output #8 (stored in _8, also as Out[8]):: In [7]: edit _8 Editing... done. Executing edited code... hello again - Out[7]: "print 'hello again'\\n" + Out[7]: "print('hello again')\\n" Changing the default editor hook: diff --git a/contrib/python/ipython/py3/IPython/core/magics/execution.py b/contrib/python/ipython/py3/IPython/core/magics/execution.py index f3688f4eb08..abfc4cbda76 100644 --- a/contrib/python/ipython/py3/IPython/core/magics/execution.py +++ b/contrib/python/ipython/py3/IPython/core/magics/execution.py @@ -1256,7 +1256,7 @@ class ExecutionMagics(Magics): Wall time: 1.37 Out[3]: 499999500000L - In [4]: %time print 'hello world' + In [4]: %time print('hello world') hello world CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s Wall time: 0.00 @@ -1406,9 +1406,9 @@ class ExecutionMagics(Magics): 44: x=1 45: y=3 46: z=x+y - 47: print x + 47: print(x) 48: a=5 - 49: print 'x',x,'y',y + 49: print('x',x,'y',y) you can create a macro with lines 44 through 47 (included) and line 49 called my_macro with:: @@ -1428,7 +1428,7 @@ class ExecutionMagics(Magics): You can view a macro's contents by explicitly printing it with:: - print macro_name + print(macro_name) """ opts,args = self.parse_options(parameter_s,'rq',mode='list') @@ -1439,7 +1439,7 @@ class ExecutionMagics(Magics): "%macro insufficient args; usage '%macro name n1-n2 n3-4...") name, codefrom = args[0], " ".join(args[1:]) - #print 'rng',ranges # dbg + # print('rng',ranges) # dbg try: lines = self.shell.find_user_code(codefrom, 'r' in opts) except (ValueError, TypeError) as e: @@ -1592,17 +1592,17 @@ def _format_time(timespan, precision=3): break return " ".join(time) - - # Unfortunately the unicode 'micro' symbol can cause problems in - # certain terminals. + + # Unfortunately characters outside of range(128) can cause problems in + # certain terminals. # See bug: https://bugs.launchpad.net/ipython/+bug/348466 # Try to prevent crashes by being more secure than it needs to # E.g. eclipse is able to print a µ, but has no sys.stdout.encoding set. - units = [u"s", u"ms",u'us',"ns"] # the save value - if hasattr(sys.stdout, 'encoding') and sys.stdout.encoding: + units = ["s", "ms", "us", "ns"] # the safe value + if hasattr(sys.stdout, "encoding") and sys.stdout.encoding: try: - u'\xb5'.encode(sys.stdout.encoding) - units = [u"s", u"ms",u'\xb5s',"ns"] + "μ".encode(sys.stdout.encoding) + units = ["s", "ms", "μs", "ns"] except: pass scaling = [1, 1e3, 1e6, 1e9] diff --git a/contrib/python/ipython/py3/IPython/core/magics/history.py b/contrib/python/ipython/py3/IPython/core/magics/history.py index faa4335faa8..8343677451f 100644 --- a/contrib/python/ipython/py3/IPython/core/magics/history.py +++ b/contrib/python/ipython/py3/IPython/core/magics/history.py @@ -128,7 +128,7 @@ class HistoryMagics(Magics): In [6]: %history -n 4-6 4:a = 12 - 5:print a**2 + 5:print(a**2) 6:%history -n 4-6 """ diff --git a/contrib/python/ipython/py3/IPython/core/magics/namespace.py b/contrib/python/ipython/py3/IPython/core/magics/namespace.py index 5da8f7161a0..737a76507f7 100644 --- a/contrib/python/ipython/py3/IPython/core/magics/namespace.py +++ b/contrib/python/ipython/py3/IPython/core/magics/namespace.py @@ -43,7 +43,7 @@ class NamespaceMagics(Magics): '%pinfo object' is just a synonym for object? or ?object.""" - #print 'pinfo par: <%s>' % parameter_s # dbg + # print('pinfo par: <%s>' % parameter_s) # dbg # detail_level: 0 -> obj? , 1 -> obj?? detail_level = 0 # We need to detect if we got called as 'pinfo pinfo foo', which can |
