Popular recipes tagged "meta:score=-2"http://code.activestate.com/recipes/tags/meta:score=-2/2016-06-01T19:36:28-07:00ActiveState Code Recipeschroma (Python) 2016-05-30T11:48:10-07:00aaahttp://code.activestate.com/recipes/users/4194184/http://code.activestate.com/recipes/580671-chroma/ <p style="color: grey"> Python recipe 580671 by <a href="/recipes/users/4194184/">aaa</a> (<a href="/recipes/tags/2d/">2d</a>, <a href="/recipes/tags/game/">game</a>). </p> <p>Python personnal game code</p> The many uses of randomness - Part 1 (Python) 2016-06-01T19:36:28-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580674-the-many-uses-of-randomness-part-1/ <p style="color: grey"> Python recipe 580674 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python2/">python2</a>, <a href="/recipes/tags/random/">random</a>, <a href="/recipes/tags/random_number/">random_number</a>). </p> <p>This recipe shows some of the many uses of random numbers, using the random function from the random module from Python's standard library. A subsequent recipe or two will show other uses, both of other functions from the module, and for other purposes.</p> <p>The uses shown in this recipe have to do with using random float values, and scaling them and offsetting them, and also how to get a repeated/predictable series of random numbers.</p> Validate product (Python) 2014-10-05T19:17:56-07:00Savu Andreeahttp://code.activestate.com/recipes/users/4190914/http://code.activestate.com/recipes/578947-validate-product/ <p style="color: grey"> Python recipe 578947 by <a href="/recipes/users/4190914/">Savu Andreea</a> . </p> <p>Necessary in commerce</p> Dice (Python) 2013-07-11T15:34:51-07:00superducktoxichttp://code.activestate.com/recipes/users/4187037/http://code.activestate.com/recipes/578601-dice/ <p style="color: grey"> Python recipe 578601 by <a href="/recipes/users/4187037/">superducktoxic</a> . </p> <p>Choose a die and the program will give you the answer.</p> Rating System (Python) 2013-04-21T11:09:06-07:00Kartikeyhttp://code.activestate.com/recipes/users/4186257/http://code.activestate.com/recipes/578512-rating-system/ <p style="color: grey"> Python recipe 578512 by <a href="/recipes/users/4186257/">Kartikey</a> . </p> <p>It gives ratings to business.</p> Directory Cleaner (Python) 2012-12-05T20:56:05-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578357-directory-cleaner/ <p style="color: grey"> Python recipe 578357 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>If there is a particular directory that you want purged of its files and want a solution in Python, this simple program is designed to do just that. This recipe is just meant as a starting point for those wondering how to delete all files and sub-folders from a central folder.</p> File To Hex (Python) 2012-12-05T23:45:05-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578360-file-to-hex/ <p style="color: grey"> Python recipe 578360 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/demonstration/">demonstration</a>). </p> <p>There are lots of hex editors out there, but how difficult is it to actually write a program that just displays a file in simple hex format? As this recipe shows, a few functions and lines in Python makes it rather easy to accomplish.</p> Create replica of the existing directory structure with only specified extension files. (Python) 2012-11-16T08:30:31-08:00Achal Rastogihttp://code.activestate.com/recipes/users/4183889/http://code.activestate.com/recipes/578303-create-replica-of-the-existing-directory-structure/ <p style="color: grey"> Python recipe 578303 by <a href="/recipes/users/4183889/">Achal Rastogi</a> (<a href="/recipes/tags/bioinformatics/">bioinformatics</a>, <a href="/recipes/tags/biology/">biology</a>, <a href="/recipes/tags/directory/">directory</a>, <a href="/recipes/tags/fileextensions/">fileextensions</a>, <a href="/recipes/tags/replica/">replica</a>). Revision 2. </p> <p>The program creates a replica of existing directory structure with specified extension files only. The program maintains the directory-sub-directory architecture while executing. User has to provide two arguments, First the path of existing directory,whose replica has to be created and Second, the path of directory, where the replica has to be created. This program is developed to fetch files with ".pl" (perl) extension, while maintaining the directory-sub-directory architecture. User can modify it, with his/her interested file extension, like ".txt", ".doc", etc.</p> My First Poem Written in Python (Python) 2011-04-06T18:09:48-07:00thermohttp://code.activestate.com/recipes/users/4177569/http://code.activestate.com/recipes/577641-my-first-poem-written-in-python/ <p style="color: grey"> Python recipe 577641 by <a href="/recipes/users/4177569/">thermo</a> (<a href="/recipes/tags/poem/">poem</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>My First Poem Written in Python</p> Easy Exception, Error Handling and Debugging with Auto Logging (Python) 2010-04-06T20:40:05-07:00AJ. Mayorgahttp://code.activestate.com/recipes/users/4173476/http://code.activestate.com/recipes/577144-easy-exception-error-handling-and-debugging-with-a/ <p style="color: grey"> Python recipe 577144 by <a href="/recipes/users/4173476/">AJ. Mayorga</a> (<a href="/recipes/tags/debug/">debug</a>, <a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/error_propagation/">error_propagation</a>, <a href="/recipes/tags/exception/">exception</a>, <a href="/recipes/tags/logging/">logging</a>). Revision 5. </p> <p>Being new to Python and trying to chase where in my project exceptions were taking place always seems to take up a large amount of time. So I created this class that I now pretty use in all my projects to help me save time tracking exceptions and errors. its also has the ability to generate error logs or to output SQL query and data tuples for Database logging. Ive added sample code to give you an idea of how I normally use it. Hope this helps its saved me hours in tracking error/exception. Feed back would be great, mind you havent been Python all that long</p> format a number as an ordinal (Python) 2010-02-04T12:54:27-08:00Serdar Tumgorenhttp://code.activestate.com/recipes/users/4171495/http://code.activestate.com/recipes/576888-format-a-number-as-an-ordinal/ <p style="color: grey"> Python recipe 576888 by <a href="/recipes/users/4171495/">Serdar Tumgoren</a> (<a href="/recipes/tags/number/">number</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/numerals/">numerals</a>, <a href="/recipes/tags/ordinals/">ordinals</a>). Revision 10. </p> <p>This function converts 0 and <em>positive</em> integers (or their string representations) to their ordinal values. For example, it would convert 0 to "0th", 1 to "1st", 2 to "2nd", 3 to "3rd" and so on.</p> Bible Verse Quiz - VerseMatch.py (Python) 2010-02-12T09:51:09-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577043-bible-verse-quiz-versematchpy/ <p style="color: grey"> Python recipe 577043 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/bible/">bible</a>, <a href="/recipes/tags/quiz/">quiz</a>, <a href="/recipes/tags/verse/">verse</a>, <a href="/recipes/tags/_versematch_/">_versematch_</a>). Revision 3. </p> <p>Run a Bible-verse-matching servlet on the network.</p> <p>This program is a port of the VerseMatch program written in CPS 110 at BJU during the Autumn Semester of 2003.</p> Bible Verse Quiz - timeout.py (Python) 2010-02-12T04:19:59-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577045-bible-verse-quiz-timeoutpy/ <p style="color: grey"> Python recipe 577045 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/bible/">bible</a>, <a href="/recipes/tags/quiz/">quiz</a>, <a href="/recipes/tags/verse/">verse</a>, <a href="/recipes/tags/_versematch_/">_versematch_</a>). Revision 2. </p> <p>Provide way to add timeout specifications to arbitrary functions.</p> <p>There are many ways to add a timeout to a function, but no solution is both cross-platform and capable of terminating the procedure. This module use the multiprocessing module to solve both of those problems.</p> Binary_Decimal Recursion (Python) 2010-02-23T04:39:41-08:00Fouad Teniouhttp://code.activestate.com/recipes/users/4155345/http://code.activestate.com/recipes/577034-binary_decimal-recursion/ <p style="color: grey"> Python recipe 577034 by <a href="/recipes/users/4155345/">Fouad Teniou</a> (<a href="/recipes/tags/mathematics/">mathematics</a>). Revision 5. </p> <p>The most commonly used number system is the denary number system, a system of numbers to base 10. However, All the others numbers systems are used in the computing field. And the binary number system, a system of numbers to base 2 uses only two digits 0 and 1, and any position in a binary number system increases by powers of 2 in contrast with the decimal system, which increases by powers of 10. <strong>Though, the binary number system was invented by a Chinese poet and philosopher Shao Yong in the 11th century.</strong> Solving repetitive problems requires a powerful method and yet recursion allows the design of faster recursive algorithms. Recursion method could be used to solve higher-level mathematics problems, such as sequences and it is a branch in computer science study.</p> Bible Verse Quiz - verse.py (Python) 2010-02-12T04:19:44-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577044-bible-verse-quiz-versepy/ <p style="color: grey"> Python recipe 577044 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/bible/">bible</a>, <a href="/recipes/tags/quiz/">quiz</a>, <a href="/recipes/tags/verse/">verse</a>, <a href="/recipes/tags/_versematch_/">_versematch_</a>). Revision 3. </p> <p>Encapsulate verses from the Bible and support quizzing over them.</p> <p>The Verse class in this module is far superior to the one implemented in Java. All quizzing/testing capabilities are imported from another module.</p> Indent a string (Python) 2009-08-05T06:26:09-07:00tat.wrighthttp://code.activestate.com/recipes/users/4171357/http://code.activestate.com/recipes/576867-indent-a-string/ <p style="color: grey"> Python recipe 576867 by <a href="/recipes/users/4171357/">tat.wright</a> (<a href="/recipes/tags/indent/">indent</a>). </p> <p>Indent a string.</p> Converty decimal/integer number to binary string in Python (Python) 2009-07-17T09:17:32-07:00Vishal Saprehttp://code.activestate.com/recipes/users/4166412/http://code.activestate.com/recipes/576847-converty-decimalinteger-number-to-binary-string-in/ <p style="color: grey"> Python recipe 576847 by <a href="/recipes/users/4166412/">Vishal Sapre</a> (<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/integer/">integer</a>, <a href="/recipes/tags/string/">string</a>). </p> <p>This is a very simple look-up based method for converting integer to binary string. In my tests, using 'timeit', its the fastest around. And with increasing value of input decimal number, it surpases any 'run time computation' based method doing the above.</p> Create SHA Hashes of a Directory (Python) 2009-04-14T08:10:26-07:00andrew.canithttp://code.activestate.com/recipes/users/4169843/http://code.activestate.com/recipes/576716-create-sha-hashes-of-a-directory/ <p style="color: grey"> Python recipe 576716 by <a href="/recipes/users/4169843/">andrew.canit</a> (<a href="/recipes/tags/encryption/">encryption</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/security/">security</a>, <a href="/recipes/tags/sha/">sha</a>). Revision 2. </p> <p>Walk through a Directory creating SHA Hashes of each file path</p> Unique lines from a text file, case sensitive or insensitive (Python) 2009-04-05T19:58:50-07:00nickhttp://code.activestate.com/recipes/users/4169647/http://code.activestate.com/recipes/576713-unique-lines-from-a-text-file-case-sensitive-or-in/ <p style="color: grey"> Python recipe 576713 by <a href="/recipes/users/4169647/">nick</a> (<a href="/recipes/tags/uniq/">uniq</a>, <a href="/recipes/tags/unique_lines/">unique_lines</a>). </p> <p>Spits out sorted, deduplicated lines.</p> 把html转化为纯文本 (Python) 2009-02-21T23:49:58-08:00nillgump nillgumphttp://code.activestate.com/recipes/users/4169273/http://code.activestate.com/recipes/576657-html/ <p style="color: grey"> Python recipe 576657 by <a href="/recipes/users/4169273/">nillgump nillgump</a> (<a href="/recipes/tags/html/">html</a>, <a href="/recipes/tags/text/">text</a>). </p> <p>把html转化为纯文本</p>