Search
New Code
.Net VCL for Delphi 1.0.0.0
ASP. NET C# PDF Software 4.5
LinqConnect Professional 4.8
CAD VCL: 2D/3D CAD in Delphi/C++Builder 14
wolfSSL 3.15.7
CAD DLL 14
AnyStock Stock and Financial JS Charts 8.4.2
ODBC Driver for SQLite 2.4
dotConnect for SugarCRM 1.7
dbForge SQL Complete 5.9
dbForge Studio for MySQL 8.0
.Net Runtime Library for Delphi 6.0.4.0
Scimbo 1.64
AnyMap JS Maps 8.4.2
GetOrgChart 2.5.3
Top Code
Paste phpSoftPro 1.4.1
Deals and Discounts Website Script 1.0.2
ADO.NET Provider for ExactTarget 1.0
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
PHP GZ Blog Script 1.1
ATN Jobs Software 4.0
ATN Mall 2.0
WeBuilder 2015 13.3
Code Listing by Alex Martelli

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






"Templating" (copying an input file to output, on the fly inserting Python expressions and statements) is a frequent need, and YAPTU is a small but complete Python module for that; expressions and statements are identified by arbitrary user-chosen regular-rexpressions.



Python does not automatically call the __init__ (and __del__) methods of superclasses if subclasses define their own; explicit calling is needed, and it may be advisable to use a call-if-it-exists idiom.



In Python, any variable can be re-bound at will -- and modules don't let you define special methods such as an instance's __setattr__ to stop attribute re-binding. Easy solution (in Python 2.1 and up): use an instance as "module"...



You want to convert tabs in a string to the appropriate number of spaces, or vice versa.



Special method __copy__ is the easiest way for an object to cooperate with the copy.copy function, but how do you bypass the object's __init__, if it's slow, to get an 'empty' object of this class? Easy -- here's how.



Python has no equivalent to Java's "super" keyword (so that some part of a method can be delegated to the superclass), but it's easy to get similar convenience despite Python's multiple-inheritance generality.



Python's "in" operator is extremely handy, but O(N) when applied to an N-item sequence; if a sequence is subject to frequent "in" tests, an auxiliary dictionary at its side can boost performance A LOT if the values are hashable.



You want to reverse the characters or words of a string.



Python's "if" is a _statement_, and there is no conditional _operator_ (like C's "a?b:c" ternary) that we could use where expressions are needed (lambdas, etc); however, with some due care, equivalents can easily be coded.



Python lists' .sort method is not guaranteed stable -- items that compare equal may or may not be in unchanged order. Ensuring stability is easy as one of the many application of the commom idiom decorate-sort-undecorate (aka "Schwartzian...