In [1]:
print("this is {py} using {mv}".format(py="python", mv="multiple variables"))
this is python using multiple variables
In [2]:
globals()
Out[2]:
{'In': ['',
u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
u'globals()'],
'Out': {},
'_': '',
'__': '',
'___': '',
'__builtin__': <module '__builtin__' (built-in)>,
'__builtins__': <module '__builtin__' (built-in)>,
'__doc__': 'Automatically created module for IPython interactive environment',
'__name__': '__main__',
'_dh': [u'/Users/louistur/Developer/Python/PythonBootcamp'],
'_i': u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
'_i1': u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
'_i2': u'globals()',
'_ih': ['',
u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
u'globals()'],
'_ii': u'',
'_iii': u'',
'_oh': {},
'_sh': <module 'IPython.core.shadowns' from '/Users/louistur/anaconda/lib/python2.7/site-packages/IPython/core/shadowns.pyc'>,
'exit': <IPython.core.autocall.ZMQExitAutocall at 0x10f5d96d0>,
'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x10f49bed0>>,
'quit': <IPython.core.autocall.ZMQExitAutocall at 0x10f5d96d0>}
In [3]:
locals()
Out[3]:
{'In': ['',
u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
u'globals()',
u'locals()'],
'Out': {2: {...}},
'_': {...},
'_2': {...},
'__': '',
'___': '',
'__builtin__': <module '__builtin__' (built-in)>,
'__builtins__': <module '__builtin__' (built-in)>,
'__doc__': 'Automatically created module for IPython interactive environment',
'__name__': '__main__',
'_dh': [u'/Users/louistur/Developer/Python/PythonBootcamp'],
'_i': u'globals()',
'_i1': u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
'_i2': u'globals()',
'_i3': u'locals()',
'_ih': ['',
u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
u'globals()',
u'locals()'],
'_ii': u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
'_iii': u'',
'_oh': {2: {...}},
'_sh': <module 'IPython.core.shadowns' from '/Users/louistur/anaconda/lib/python2.7/site-packages/IPython/core/shadowns.pyc'>,
'exit': <IPython.core.autocall.ZMQExitAutocall at 0x10f5d96d0>,
'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x10f49bed0>>,
'quit': <IPython.core.autocall.ZMQExitAutocall at 0x10f5d96d0>}
In [4]:
x = 50
In [5]:
locals()
Out[5]:
{'In': ['',
u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
u'globals()',
u'locals()',
u'x = 50',
u'locals()'],
'Out': {2: {...}, 3: {...}},
'_': {...},
'_2': {...},
'_3': {...},
'__': {...},
'___': '',
'__builtin__': <module '__builtin__' (built-in)>,
'__builtins__': <module '__builtin__' (built-in)>,
'__doc__': 'Automatically created module for IPython interactive environment',
'__name__': '__main__',
'_dh': [u'/Users/louistur/Developer/Python/PythonBootcamp'],
'_i': u'x = 50',
'_i1': u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
'_i2': u'globals()',
'_i3': u'locals()',
'_i4': u'x = 50',
'_i5': u'locals()',
'_ih': ['',
u'print("this is {py} using {mv}".format(py="python", mv="multiple variables"))',
u'globals()',
u'locals()',
u'x = 50',
u'locals()'],
'_ii': u'locals()',
'_iii': u'globals()',
'_oh': {2: {...}, 3: {...}},
'_sh': <module 'IPython.core.shadowns' from '/Users/louistur/anaconda/lib/python2.7/site-packages/IPython/core/shadowns.pyc'>,
'exit': <IPython.core.autocall.ZMQExitAutocall at 0x10f5d96d0>,
'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x10f49bed0>>,
'quit': <IPython.core.autocall.ZMQExitAutocall at 0x10f5d96d0>,
'x': 50}
In [6]:
help(locals)
Help on built-in function locals in module __builtin__:
locals(...)
locals() -> dictionary
Update and return a dictionary containing the current scope's local variables.
In [ ]:
Content source: spacedrabbit/PythonBootcamp
Similar notebooks: