goto in Python
You can use exceptions to provide a 'structured goto' that even works across function calls. Many feel that exceptions can conveniently emulate all reasonable uses of the 'go' or '
Read tutorialTHE TUTORIAL LIBRARY
You can use exceptions to provide a 'structured goto' that even works across function calls. Many feel that exceptions can conveniently emulate all reasonable uses of the 'go' or '
Read tutorialThe details of Python memory management depend on the implementation. The standard C implementation of Python uses reference counting to detect inaccessible objects, and another me
Read tutorialThere is no switch or case statement in Python. Because, you can do this easily enough with a sequence of if... elif... elif... else. There have been some proposals for switch stat
Read tutorialThis answer on how to overload in python actually applies to all methods, but the question usually comes up first in the context of constructors.
Read tutorialBoth static data and static methods (in the sense of C++ or Java) are supported in Python. For static data, simply define a class attribute. To assign a new value to the attribute,
Read tutorialDelegation is an object oriented technique (also called a design pattern). Let's say you have an object x and want to change the behaviour of just one of its methods. You can creat
Read tutorialThe technique, attributed to Randal Schwartz of the Perl community, sorts the elements of a list by a metric which maps each element to its "sort value". In Python, just use the ke
Read tutorialThe reason is that replicating a list with * doesn't create copies, it only creates references to the existing objects. The *3 creates a list containing 3 references to the same li
Read tutorialLists are equivalent to C or Pascal arrays in their time complexity; the primary difference is that a Python list can contain objects of many different types.
Read tutorialIf you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as you go
Read tutorialUse the reversed() built-in function, which is new in Python 2.4
Read tutorialThe type constructor tuple(seq) converts any sequence (actually, any iterable) into a tuple with the same items in the same order.
Read tutorialOne example today. A better developer tomorrow.