Popular recipes tagged "source" but not "linux"http://code.activestate.com/recipes/tags/source-linux/2016-10-25T17:53: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> Find what class an attribute - ie, myObj.myAttr - comes from, and how it's defined (Python) 2012-10-26T12:59:47-07:00Paul Molodowitchhttp://code.activestate.com/recipes/users/4184064/http://code.activestate.com/recipes/578305-find-what-class-an-attribute-ie-myobjmyattr-comes-/ <p style="color: grey"> Python recipe 578305 by <a href="/recipes/users/4184064/">Paul Molodowitch</a> (<a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/attributes/">attributes</a>, <a href="/recipes/tags/class/">class</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/inspection/">inspection</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/__dict__/">__dict__</a>, <a href="/recipes/tags/__getattribute__/">__getattribute__</a>, <a href="/recipes/tags/__getattr__/">__getattr__</a>, <a href="/recipes/tags/__slots__/">__slots__</a>). Revision 3. </p> <p>When inspecting new code (or when debugging), it can be handy to know exactly where a given attribute on an object or class comes from.</p> <p>As a simple example, if you have a class MyClass, you might want to know where MyClass().myMethod is defined.</p> <p>However, things can get tricky when things like __getattr__, __getattribute__, or even compiled objects come into play. That's where this function comes in. It returns what class a given attribute comes from, and what method was used to define it - ie, '__dict__' ('normal' definitions), '__slots__', '__getattr__', '__getattribute__', '(BUILTIN)'.</p> <p>(Note - this function should't be relied on to be 100% accurate - rather, it's a best guess, for where to look to find it. It takes some pretty infrequent edge cases for it to be wrong, though...)</p> Pastebin Upload (Python) 2013-05-26T10:54:25-07:00Joe Smithhttp://code.activestate.com/recipes/users/4168055/http://code.activestate.com/recipes/576805-pastebin-upload/ <p style="color: grey"> Python recipe 576805 by <a href="/recipes/users/4168055/">Joe Smith</a> (<a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/post/">post</a>, <a href="/recipes/tags/source/">source</a>, <a href="/recipes/tags/urllib2/">urllib2</a>). Revision 2. </p> <p>A little script I made for some buddies and I. We are constantly collaborating on code. This scrips takes a source code file as it's parameter and uploads it to <a href="http://pastebin.com" rel="nofollow">pastebin.com</a> or any sub domain of pastebin. I integrated it with the righ click window in windows. Without that integration the script wouldn't be as cool! Hope others find it useful.</p>