In [1]: msgflag = 1
In [2]: pi = 3
In [3]: msg = "hello"
In [4]: warning = None
In [5]: msg
msg msgflag
In [5]: who
msg msgflag pi warning
In [6]: who int
msgflag pi
In [7]: whos Variable Type Data/Info -------------------------------- msg str hello msgflag int 1 pi int 3 warning NoneType None
In [8]: psearch msg*
msg
msgflag
In [9]: psearch msg* int
msgflag
In [10]: store msgflag
Stored 'msgflag' (int)
In [11]: store msgflag > /tmp/m.txt
Writing 'msgflag' (int) to file '/tmp/m.txt'.
In [12]: store
Stored variables and their in-db values:
msgflag -> 1
In [13]: reset
Once deleted, variables cannot be recovered. Proceed (y/[n])? y
In [14]: who
Interactive namespace is empty.
In [15]: store -r
In [16]: who
msgflag
In [17]: store -z
In [18]: logstate
Logging has not been activated.
In [19]: logstart
Activating auto-logging. Current session state plus future input saved.
Filename : ipython_log.py
Mode : rotate
Output logging : False
Raw input log : False
Timestamping : False
State : active
In [20]: logoff
Switching logging OFF
In [21]: logon
Switching logging ON
In [22]: lsmagic
Available magic functions:
%Exit %Pprint %Quit %alias %autocall %autoindent %automagic %bg %bookmark %cd %clear %color_info %colors %cpaste %debug %dhist %dirs %doctest_mode %ed %edit %env %exit %hist %history %logoff %logon %logstart %logstate %logstop %lsmagic %macro %magic %p %page %pdb %pdef %pdoc %pfile %pinfo %popd %profile %prun %psearch %psource %pushd %pwd %pycat %quickref %quit %r %rehash %rehashx %rep %reset %run %runlog %save %sc %store %sx %system_verbose %time %timeit %unalias %upgrade %who %who_ls %whos %xmode
Automagic is ON, % prefix NOT needed for magic functions.
In [23]: lsmagic?
Type: Magic function
Base Class: <type 'instancemethod'>
String Form: <bound method InteractiveShell.magic_lsmagic of <IPython.iplib.InteractiveShell object at 0x9e5ef0>>
Namespace: IPython internal
File: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ipython-0.9.1-py2.5.egg/IPython/Magic.py
Definition: lsmagic(self, parameter_s='')
Docstring:
List currently available magic functions.
In [24]: msgflag?
Type: int
Base Class: <type 'int'>
String Form: 1
Namespace: Interactive
Docstring:
int(x[, base]) -> integer
Convert a string or number to an integer, if possible. A floating point
argument will be truncated towards zero ...
In [25]: import sys
In [26]: p sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.5/bin', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/bdist_mpkg-0.4.3-py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/macholib-1.1-py2.5.egg',
...
In [27]: def x(a, b):
....: print a, b
....:
....:
In [28]: x 3, 4
-------> x(3, 4)
3 4
In [29]: def x(): print "123"
....:
In [30]: /x
-------> x()
123
In [31]: def x(a,b): print "%s-%s" % (a, b)
....:
In [32]: , x astr bstr
-------> x("astr", "bstr")
astr-bstr
In [37]: import re
In [38]: pdef re.match
re.match(pattern, string, flags=0)
In [39]: pdoc re.match
Class Docstring:
Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found.
Calling Docstring:
x.__call__(...) <==> x(...)
In [40]: pinfo re.match
Type: function
Base Class: <type 'function'>
String Form: <function match at 0xaa2b70>
Namespace: Interactive
File: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py
Definition: re.match(pattern, string, flags=0)
Docstring:
Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found.
In [41]: psource re.match
def match(pattern, string, flags=0):
"""Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found."""
return _compile(pattern, flags).match(string)
In [42]: pfile re.match
In [43]: edit -x re.match
Editing...
Source: https://habr.com/ru/post/49685/
All Articles