On Tuesday, February 18, 2014 10:47:15 AM UTC-6, Chris Angelico wrote: > I call this "Russian Exception Roulette". It came about because of > some discussions on python-ideas regarding the new PEP 463 and > exception handling. > try: > > exc = getattr(__builtins__,random.choice(list(filter(lambda x: > x.endswith("Error"),dir(__builtins__))))) > f() > except exc: > print("You win!") > Given a function f(), defined elsewhere, what will this do?
For get about "f()", it will throw a NameError since "random" was not imported. Beyond that this code (either conscientiously or unconsciously) exposes the onerous and obfuscation of a language design that coddles a global function nightmare paradigm over the elegance of true OOP -- talk about cutting off your nose just to spite your face! -- https://mail.python.org/mailman/listinfo/python-list