Search
New Code
Code Review Bundle 1.0
Magento Delivery Date Scheduler 1.0
Devart Excel Add-ins 1.8
Faculty Evaluation System 1.1
dbForge Studio for PostgreSQL 2.0
Yelp Script - Yelp Clone 1.3
Database Workbench Pro 5.4.6
Extensibility Studio 3.0
Bytescout Spreadsheet SDK 3.0.0.1699
Magento 2 Admin Mobile App 1.0
Data Compare for MySQL 5.3
ODBC Driver for Zoho CRM 1.3
ODBC Driver for SugarCRM 1.3
Bytescout PDF To HTML SDK 9.0.0.3079
Azizi search engine script PHP 4.1.10
Top Code
Output Messenger 1.8.0
Aliexpress Clone- Ec21 Script 1
Indiegogo Clone 3.0
Advanced MLM Software 1.2
Online Food Ordeing System 1.0
PHP Image Resize Script 1.0
Best Spotify Clone 1.0
Get Random Record Based on Weight 1.0.0
PHP Point of sale 10.0
Travel Portal Script 9.29
Excel Add-in for Bigcommerce 1.6
Magento Product Designer 1.0
OFOS - Just Eat Clone Script 1.0
PrestaShop Upload Images Module 1.2.1
Trading Software 1.2.4
Code Listing by Steven D'Aprano

Code 1-10 of 15   Pages: Go to  1  2  Next >>  page  






dir() is useful for interactively exploring the attributes and methods of objects at the command line. But sometimes dir() returns a lot of information:

>>> len(dir(decimal.Decimal)) # too much information!
137


It can be helpful to filter the list of names returned. This enhanced version of dir does exactly that, using simple string globbing:

>>> dir(decimal.Decimal, '*log*') #...



This function allows you to calculate the Method Resolution Order (MRO, or sometimes linearization) of a class or base classes. This is the so-called "C3" algorithm, as used by Python (new-style classes, from version 2.3 and higher). The...



In Python 3, the map builtin silently drops any excess items in its input:

>>> a = [1, 2, 3]
>>> b = [2, 3, 4]
>>> c = [3, 4, 5, 6, 7]
>>> list(map(lambda x,y,z: x*y+z, a, b, c))



Generic "approximately equal" function for any object type, with customisable error tolerance.

When called with float arguments, approx_equal(x, y[, tol[, rel]) compares x and y numerically, and returns True if y is within...



This is a validation function for Australian Company Numbers (ACNs). It tests whether the integer or string is a valid ACN (but not whether it is a legal ACN, i.e. if it belongs to the company that is quoting it).



The Python standard library comes with an extensive set of regression tests. I had need to import and run some of these tests from my own code, but the test directory is not in Python's path. This simple helper function solves the problem.



The list and tuple index() method and in operator test for element containment, unlike similar tests for strings, which checks for sub-strings:

>>> "12" in "0123"
True
>>> [1, 2] in [0, 1,...



The integer square root function, or isqrt, is equivalent to floor(sqrt(x)) for non-negative x. For small x, the most convenient way to calculate isqrt is by calling int(x**0.5) or int(math.sqrt(x)), but if x is a large enough integer, the sqrt...



See the recipe here for a description of the problem.

This variant allows the user to choose between two APIs, either by supplying the count, start value and end value:

>>> list(spread(5, 1.0, end=2.0))
[1.0,...



This descriptor can be used to decorate methods, similar to the built-ins classmethod and staticmethod. It enables the caller to call methods on either the class or an instance, and the first argument passed to the method will be the class or the...