On Thu, 05 Oct 2006 00:02:51 +0200, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Jorgen Grahn wrote:
> Any use cases for these? >> - the wildcard object, which compares equal to everything else Like someone else wrote, for quick-and-dirty comparisons or lists and dictionaries where I don't care about one part. I think I wanted it for unittest's assertEqual(foo, bar) at one point. self.assertEqual(['foo', 42, [], WILDCARD], my_result) versus self.assertEqual('foo', my_result[0]) self.assertEqual(42, my_result[1]) self.assertEqual([], my_result[2]) self.assertEqual(4, len(my_result)) # possibly assert that 'my_result' is a list-like # object too But I agree that the WILDCARD isn't the kind of object you want to spread throughout your code; its behaviour is too odd. >> - infinite xrange()s Available in itertools, as someone pointed out. >> - the black hole function 'def f(*args): pass' I often find myself adding logging to functions by passing sys.stderr.write as an argument to it. Passing blackhole is an elegant and fast way of disabling logging. >> - the identity function 'def f(x): return x' I don't think I've used it. Maybe if you do a lot of manipulation of functions and functors -- in some sense it's to function application what 0 is to addition, or 1 to multiplication. /Jorgen -- // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list