Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

OP has: "did you call SomeClass() twice? Then a is b will always be False."

Not quite. SomeClass can have an implementation of __new__ which returns the same object upon every invocation. In this case "SomeClass() is SomeClass()" will be True. People sometimes do this and call SomeClass a "singleton".



Yeah, I wasn't crazy about the implication that str and int only do this via special built-in magic. In reality, you can overload __new__ to return whatever you want, including object interning.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: