Popular recipes by Jean Brouwers http://code.activestate.com/recipes/users/2984142/popular/2017-07-22T15:52:01-07:00ActiveState Code RecipesLines Of Code (LOC) (Python)
2016-10-25T17:53:01-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/580709-lines-of-code-loc/
<p style="color: grey">
Python
recipe 580709
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/count/">count</a>, <a href="/recipes/tags/lines/">lines</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/source/">source</a>).
Revision 3.
</p>
<p>Count the number of lines (code, comment, blank) in one or several Python source files.</p>
Size of Python objects (revised). (Python)
2017-07-22T15:52:01-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/546530-size-of-python-objects-revised/
<p style="color: grey">
Python
recipe 546530
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/getsizeof/">getsizeof</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/sizeof/">sizeof</a>).
Revision 21.
</p>
<p>This recipe determines the size of Python objects in bytes and has been further enhanced to handle ints, namedtuples, arrays and NumPy types better. Functions <em>alen</em> and <em>itemsize</em> have been updated. Support for Python 2.5 and earlier and the tests/examples have been removed. See project <a href="https://github.com/pympler/pympler">Pympler</a> for unit tests.</p>
<p>See also other, simpler recipes like this <a href="http://code.activestate.com/recipes/577504">Compute memory footprint of an object and its contents</a>.</p>
IP and MAC addresses (Python)
2016-07-07T17:52:15-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/577191-ip-and-mac-addresses/
<p style="color: grey">
Python
recipe 577191
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/ios/">ios</a>, <a href="/recipes/tags/ip/">ip</a>, <a href="/recipes/tags/ipv4/">ipv4</a>, <a href="/recipes/tags/mac/">mac</a>, <a href="/recipes/tags/macos/">macos</a>, <a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/python2_4/">python2_4</a>, <a href="/recipes/tags/python3_5/">python3_5</a>, <a href="/recipes/tags/uuid/">uuid</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 3.
</p>
<p>This module collects all IP and MAC addresses from several available sources on the underlying system. See the module documentation for more details, supported Python releases and platforms.</p>
Timeout for (nearly) any callable (Python)
2010-12-20T06:51:35-08:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/576780-timeout-for-nearly-any-callable/
<p style="color: grey">
Python
recipe 576780
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/threads/">threads</a>, <a href="/recipes/tags/timeout/">timeout</a>).
Revision 5.
</p>
<p>This recipe provides 2 ways to invoke any callable with a time limit. Usable for Python 2.2 thru 3.0, see the Note in the module __doc__.</p>
Size of Python objects. (Python)
2008-08-27T15:38:41-07:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/544288-size-of-python-objects/
<p style="color: grey">
Python
recipe 544288
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
.
Revision 4.
</p>
<p>This recipe may be useful to determine the size in bytes of a Python object or a collection of Python objects. Function asizeof returns the combined size of all objects passed as positional arguments using 4 options given as keyword arguments.</p>
<p>Note, this recipe has been replaced by this one <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/546530">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/546530</a>.</p>
PyChecker postprocessor (Python)
2017-01-10T21:19:34-08:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/546532-pychecker-postprocessor/
<p style="color: grey">
Python
recipe 546532
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/flake8/">flake8</a>, <a href="/recipes/tags/mccabe/">mccabe</a>, <a href="/recipes/tags/pep8/">pep8</a>, <a href="/recipes/tags/pychecker/">pychecker</a>, <a href="/recipes/tags/pycodestyle/">pycodestyle</a>, <a href="/recipes/tags/pyflakes/">pyflakes</a>).
Revision 20.
</p>
<p>This recipe can separate the output of PyChecker, PyFlakes, PyCodeStyle (formerly Pep8) and/or McCabe into OK'd and regular warning messages.</p>
<p>If invoked from Python 3+, this recipe with run Flake8 by default. Command line option -3 allows running Python 3+ versions of the checkers. </p>
<p>An example is included further below. See the module documentation or -help for more details, versions, etc.</p>
backtrace2line - stack traces with source file name and line numbers (Python)
2010-12-20T06:57:29-08:00Jean Brouwershttp://code.activestate.com/recipes/users/2984142/http://code.activestate.com/recipes/534147-backtrace2line-stack-traces-with-source-file-name-/
<p style="color: grey">
Python
recipe 534147
by <a href="/recipes/users/2984142/">Jean Brouwers</a>
(<a href="/recipes/tags/backtrace/">backtrace</a>, <a href="/recipes/tags/backtrace_symbols_fd/">backtrace_symbols_fd</a>, <a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/linux/">linux</a>, <a href="/recipes/tags/stack/">stack</a>, <a href="/recipes/tags/stacktrace/">stacktrace</a>).
Revision 3.
</p>
<p>This recipe reads a file containing stack traces from Linux' backtrace functions and extends each stack frame line with the source file name and line number. Usage and an example are included.</p>