corner-case

Enum declared outside class scope

I went to this interview for a software developer position and they gave me a test with some corner-case-code situations, with usually 4 options to choose. One of the questions had an enum declared outside the class scope, I promptly checked the "does not compile" answer and went ahead with the other questions. It was something like: en...

Why can't I pass self as a named argument to an instance method in Python?

This works: >>> def bar(x, y): ... print x, y ... >>> bar(y=3, x=1) 1 3 And this works: >>> class Foo(object): ... def bar(self, x, y): ... print x, y ... >>> z = Foo() >>> z.bar(y=3, x=1) 1 3 And even this works: >>> Foo.bar(z, y=3, x=1) 1 3 But why doesn't this work? >>> Foo.bar(self=z, y=3, x=1) Traceback...

var undefined = true;

I'm doing some experimenting with this malicious JavaScript line: var undefined = true; Every uninitialized variable in JavaScript has the value of undefined which is just a variable that holds the special value of 'undefined', so the following should execute the alert: var undefined = true, x; if (x) { alert('ok'); } But i...