see is useful because it is useful when checking methods and variables in the library. This is useful when you want to check if all the methods are included when you add a new library, or when you want to check what variables the class has.
I will omit the introduction method because I think that it will come out soon if I check it. Basically, I use it on terminal (Mac OSX, Yosemite) without writing it in a script. Click here for the source https://github.com/araile/see/blob/develop/see.py
check.
$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import see
>>> see.see(see)
help() .PY_300 .PY_301 .SYMBOLS .SeeError()
.fcntl .fn_filter() .fnmatch .inspect .line_width()
.re .regex_filter() .see() .struct .sys
.term_width() .termios .textwrap
Like this, you can easily check what is in the library.
If you look at the output, you can see that it uses a standard library such as .re .fnmatch .sys
. Those with ()
are methods, and those without ()
are variables, so it is very easy to understand.
It would be better if there was argument information etc ...
My personal favorites are .fn_filter ()
and .regex_filter ()
.
fn_filter (names, pat)
simply puts an iteration in the first argument and a pattern in the second argument.
If you normally put see.see (see)
in the first argument, the above output will be passed. The second argument is a regular expression used in ShellScript? If you put in, the one that matches the pattern will be returned as a tuple.
By the way, fn
in fn_filter
means fnmatch
. So, as the name suggests, this function just applies filter
with fnmatch
.
Below is a simple example. The first is a variable and the second is a function only.
The one with .
at the beginning is included becauserepr ()
and+
are mixed depending on the library.
test_fn_filter.
>>> see.fn_filter(see.see(see), '.*[0-9a-zA-Z]')
('.PY_300', '.PY_301', '.SYMBOLS', '.fcntl', '.fnmatch', '.inspect', '.re', '.struct', '.sys', '.termios', '.textwrap')
>>> see.fn_filter(see.see(see), '.*)')
('.SeeError()', '.fn_filter()', '.line_width()', '.regex_filter()', '.see()', '.term_width()')
Then regex_filter ()
Again, as the name suggests, regex is a regular expression.
Apply filter
with re.match
in the standard library re
and output as a tuple.
So, the first argument is the same as fn_filter
, and thesecond argument is a regular expression. Basically, it is used in the same way as
fn_filter`, so the explanation is omitted.
Personally, I use fn_filter when I want to see functions and variables, and regex_filter when I want to find something that contains a certain string.
You can see what I didn't explain by looking at the source code.
Recommended Posts