diff -r d1e6a48dfb0d Doc/howto/functional.rst --- a/Doc/howto/functional.rst Sun Jan 20 01:31:20 2013 +0100 +++ b/Doc/howto/functional.rst Sun Jan 20 11:04:09 2013 +0530 @@ -479,13 +479,13 @@ You could equally write ``for i in generate_ints(5)``, or ``a,b,c = generate_ints(3)``. -Inside a generator function, the ``return`` statement can only be used without a -value, and signals the end of the procession of values; after executing a +Inside a generator function, the ``return`` statement when used without a +value signals the end of the procession of values; after executing a ``return`` the generator cannot return any further values. ``return`` with a -value, such as ``return 5``, is a syntax error inside a generator function. The -end of the generator's results can also be indicated by raising -:exc:`StopIteration` manually, or by just letting the flow of execution fall off -the bottom of the function. +value, such as ``return 5``, is semantically equivalent to +``raise StopIteration(value)``. The end of the generator's results can also +be indicated by just letting the flow of execution fall off the bottom of the +function. You could achieve the effect of generators manually by writing your own class and storing all the local variables of the generator as instance variables. For diff -r d1e6a48dfb0d Lib/uuid.py --- a/Lib/uuid.py Sun Jan 20 01:31:20 2013 +0100 +++ b/Lib/uuid.py Sun Jan 20 11:04:09 2013 +0530 @@ -46,6 +46,8 @@ __author__ = 'Ka-Ping Yee ' +import functools + RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [ 'reserved for NCS compatibility', 'specified in RFC 4122', 'reserved for Microsoft compatibility', 'reserved for future definition'] @@ -53,6 +55,7 @@ int_ = int # The built-in int type bytes_ = bytes # The built-in bytes type +@functools.total_ordering class UUID(object): """Instances of the UUID class represent UUIDs as specified in RFC 4122. UUID objects are immutable, hashable, and usable as dictionary keys. @@ -187,11 +190,6 @@ return self.int == other.int return NotImplemented - def __ne__(self, other): - if isinstance(other, UUID): - return self.int != other.int - return NotImplemented - # Q. What's the value of being able to sort UUIDs? # A. Use them as keys in a B-Tree or similar mapping. @@ -200,21 +198,6 @@ return self.int < other.int return NotImplemented - def __gt__(self, other): - if isinstance(other, UUID): - return self.int > other.int - return NotImplemented - - def __le__(self, other): - if isinstance(other, UUID): - return self.int <= other.int - return NotImplemented - - def __ge__(self, other): - if isinstance(other, UUID): - return self.int >= other.int - return NotImplemented - def __hash__(self): return hash(self.int)