Bad Code Snippet of the Day
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.
> exc = getattr(__builtins__,random.choice(list(filter(lambda x:
> 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!